After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 722892 - Linking personas on Dummy backend does not work
Linking personas on Dummy backend does not work
Status: RESOLVED FIXED
Product: folks
Classification: Platform
Component: Dummy backend
git master
Other Linux
: Normal normal
: Unset
Assigned To: folks-maint
folks-maint
Depends on:
Blocks:
 
 
Reported: 2014-01-24 08:42 UTC by Renato Araujo Oliveira Filho
Modified: 2014-03-10 22:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
unit test linkable properties for dummy backend. (10.95 KB, patch)
2014-01-24 08:43 UTC, Renato Araujo Oliveira Filho
none Details | Review
Fixed unit test to link contacts (13.78 KB, patch)
2014-02-11 17:12 UTC, Renato Araujo Oliveira Filho
none Details | Review
test log (19.11 KB, text/x-log)
2014-02-11 17:14 UTC, Renato Araujo Oliveira Filho
  Details
unit test linkable properties for dummy backend. (13.82 KB, patch)
2014-03-01 17:00 UTC, Renato Araujo Oliveira Filho
needs-work Details | Review
unit test linkable properties for dummy backend. (13.70 KB, patch)
2014-03-09 19:58 UTC, Renato Araujo Oliveira Filho
needs-work Details | Review
dummy: Add Folks.DummyPersona.update_linkable_properties() (14.41 KB, patch)
2014-03-10 22:21 UTC, Philip Withnall
committed Details | Review

Description Renato Araujo Oliveira Filho 2014-01-24 08:42:44 UTC
Adding personas with the same e-mail address does not cause they to get linked even setting the right values for linkable_properties.
Comment 1 Renato Araujo Oliveira Filho 2014-01-24 08:43:47 UTC
Created attachment 267106 [details] [review]
unit test  linkable properties for dummy backend.
Comment 2 Renato Araujo Oliveira Filho 2014-02-11 17:12:45 UTC
Created attachment 268816 [details] [review]
Fixed unit test to link contacts
Comment 3 Renato Araujo Oliveira Filho 2014-02-11 17:14:40 UTC
Created attachment 268817 [details]
test log
Comment 4 Philip Withnall 2014-02-11 22:26:27 UTC
The linking wasn’t working because the dummy persona store was untrusted — a store needs to be fully trusted (PersonaStoreTrust.FULL) for linking by linkable properties to be allowed.

The following diff makes the test pass for me:

diff --git a/tests/dummy/linkable-properties.vala b/tests/dummy/linkable-properties.vala
index 29cdfec..a0ece7b 100644
--- a/tests/dummy/linkable-properties.vala
+++ b/tests/dummy/linkable-properties.vala
@@ -59,6 +59,13 @@ public class LinkablePropertiesTests : DummyTest.TestCase
       this._found_after_update = false;
     }
 
+  public override void configure_primary_store ()
+    {
+      base.configure_primary_store ();
+
+      this.dummy_persona_store.update_trust_level (PersonaStoreTrust.FULL);
+    }
+
   private async void _add_persona (owned Gee.HashMap<string, Value?> c)
     {
       HashTable<string, Value?> details = new HashTable<string, Value?>
@@ -118,7 +125,6 @@ public class LinkablePropertiesTests : DummyTest.TestCase
   private async void _add_personas ()
     {
       Gee.HashMap<string, Value?> c;
-      this._main_loop = new GLib.MainLoop (null, false);
       Value? v;
 
       this._found_before_update = false;
Comment 5 Travis Reitter 2014-02-26 03:47:01 UTC
Renato, do Philip's changes work for you as well?
Comment 6 Renato Araujo Oliveira Filho 2014-03-01 17:00:20 UTC
Created attachment 270632 [details] [review]
unit test  linkable properties for dummy backend.
Comment 7 Renato Araujo Oliveira Filho 2014-03-01 17:01:16 UTC
(In reply to comment #5)
> Renato, do Philip's changes work for you as well?
Yes the changes works, I have update the patch, in case of you want to merge it on mainline. 

Thanks
Comment 8 Philip Withnall 2014-03-04 00:05:14 UTC
Review of attachment 270632 [details] [review]:

Good start; just a few things to tidy up. Thanks!

::: backends/dummy/lib/dummy-persona.vala
@@ +233,3 @@
     }
 
+  public void update_linkable_properties (string[] linkable_properties)

This method needs a documentation comment.

@@ +235,3 @@
+  public void update_linkable_properties (string[] linkable_properties)
+    {
+      var new_linkable_properties = new HashSet<string> ();

Please use Folks.Generics.SmallSet<string> here. It’s less memory-intensive than HashSet<string>.

@@ +236,3 @@
+    {
+      var new_linkable_properties = new HashSet<string> ();
+      new_linkable_properties.add_all_array(linkable_properties);

Need a space before ‘(’.

@@ +256,3 @@
+                }
+            }
+        }

You can use Folks.Internal.equal_sets() to compare this._linkable_properties and new_linkable_properties. Should make the code a bit smaller.

@@ +259,3 @@
+      if (changed == true)
+        {
+          this._linkable_properties = new_linkable_properties.to_array ();

Instead of new_linkable_properties.to_array(), you could just use linkable_properties.

::: tests/dummy/linkable-properties.vala
@@ +1,2 @@
+/*
+ * Copyright (C) 2012 Collabora Ltd.

Copyright’s wrong.

@@ +120,3 @@
+   *
+   * FIXME: this test should be moved to tests/folks and rebased upon the Dummy
+   * backend once bgo#648811 is fixed.

This FIXME is fixed, isn’t it?
Comment 9 Renato Araujo Oliveira Filho 2014-03-09 19:58:44 UTC
Created attachment 271372 [details] [review]
unit test  linkable properties for dummy backend.
Comment 10 Renato Araujo Oliveira Filho 2014-03-09 19:59:15 UTC
Patch fixed, based on comments above.
Comment 11 Philip Withnall 2014-03-10 22:05:14 UTC
Review of attachment 271372 [details] [review]:

::: backends/dummy/lib/dummy-full-persona.vala
@@ +116,3 @@
       this._roles_ro = this._roles.read_only_view;
       this._anti_links_ro = this._anti_links.read_only_view;
+      this.update_linkable_properties(FullPersona._default_linkable_properties);

Need a space before the ’(’.

::: backends/dummy/lib/dummy-persona.vala
@@ +237,3 @@
+   *
+   * Update the {@link Folks.Persona.linkable_properties} property to contain
+   * the given ``writeable_properties``.

s/writeable_properties/linkable_properties/.

::: tests/dummy/linkable-properties.vala
@@ +1,2 @@
+/*
+ * Copyright (C) 2012 Collabora Ltd.

Copyright’s still wrong.
Comment 12 Philip Withnall 2014-03-10 22:21:55 UTC
Created attachment 271485 [details] [review]
dummy: Add Folks.DummyPersona.update_linkable_properties()

Allow the linkable properties of a dummy persona to be edited. This
includes a unit test.

New API:
 • Folks.DummyPersona.update_linkable_properties()
Comment 13 Philip Withnall 2014-03-10 22:22:59 UTC
I just pushed a version of the patch to master with the above comments fixed. Thanks for your work on this.

Attachment 271485 [details] pushed as 77d3910 - dummy: Add Folks.DummyPersona.update_linkable_properties()