GNOME Bugzilla – Bug 722892
Linking personas on Dummy backend does not work
Last modified: 2014-03-10 22:23:03 UTC
Adding personas with the same e-mail address does not cause they to get linked even setting the right values for linkable_properties.
Created attachment 267106 [details] [review] unit test linkable properties for dummy backend.
Created attachment 268816 [details] [review] Fixed unit test to link contacts
Created attachment 268817 [details] test log
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;
Renato, do Philip's changes work for you as well?
Created attachment 270632 [details] [review] unit test linkable properties for dummy backend.
(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
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?
Created attachment 271372 [details] [review] unit test linkable properties for dummy backend.
Patch fixed, based on comments above.
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.
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()
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()