Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
authorFredrik Wendt <fredrik@wendt.se>
Tue, 8 Jun 2010 22:37:08 +0000 (23:37 +0100)
committerFredrik Wendt <fredrik@wendt.se>
Tue, 8 Jun 2010 22:37:08 +0000 (23:37 +0100)
Signed-off-by: Fredrik Wendt <fredrik@wendt.se>

package/src/org/maemo/hermes/engine/twitter/service.py
package/test/unit/test_twitter.py

index 273b99d..a0b0408 100644 (file)
@@ -53,13 +53,12 @@ class Service(org.maemo.hermes.engine.service.Service):
     
     # -----------------------------------------------------------------------
     def process_contact(self, contact):
-        if self._friends_by_contact.has_key(contact):
-            return
+        if self._friends_by_contact.has_key(contact) or \
+            self._match_contact_to_friend_by_urls(contact) or \
+            self._match_contact_to_friend_by_identifiers(contact):
+            return self._get_friend_by_contact(contact)
         
-        if self._match_contact_to_friend_by_urls(contact):
-            return
-        
-        self._match_contact_to_friend_by_identifiers(contact)
+        return None
     
     
     # -----------------------------------------------------------------------
@@ -80,6 +79,11 @@ class Service(org.maemo.hermes.engine.service.Service):
     # -----------------------------------------------------------------------
     def _get_tweeters(self):
         return self._twitter.GetFriends()
+    
+    
+    # -----------------------------------------------------------------------
+    def _get_friend_by_contact(self, contact):
+        return self._friends_by_contact[contact]
 
 
     def _match_contact_to_friend_by_urls(self, contact):
@@ -105,6 +109,7 @@ class Service(org.maemo.hermes.engine.service.Service):
 
 
     def _register_match(self, contact, friend):
+        friend.set_contact(contact)
         self._friends_by_contact[contact] = friend
         self._friends.remove(friend)
 
index dd1621a..cdbb882 100644 (file)
@@ -47,6 +47,7 @@ class TestTwitterService(unittest.TestCase):
         matchers = self.testee.get_contacts_with_match()
         assert contact in matchers
         assert twitterName == matchers[contact].get_name()
+        assert contact == self.testee._get_friend_by_contact(contact)['contact']
     
     
     def test_name_collision_avoided_by_previous_matching(self):
@@ -61,6 +62,7 @@ class TestTwitterService(unittest.TestCase):
         assert len(self.testee.get_unmatched_friends()) == 1
         matchers = self.testee.get_contacts_with_match()
         assert contact in matchers
+        assert contact == self.testee._get_friend_by_contact(contact)['contact']
 
 
     def test_name_collision_avoided_only_one_person_matched(self):
@@ -77,6 +79,8 @@ class TestTwitterService(unittest.TestCase):
         matchers = self.testee.get_contacts_with_match()
         assert contact in matchers
         assert screen_name == matchers[contact].get_nickname()
+        assert contact == matchers[contact]['contact']
+        assert contact == self.testee._get_friend_by_contact(contact)['contact']
         
 
     def _exercise_service(self, contacts):

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment