Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
authorAndrew Flegg <andrew@bleb.org>
Sat, 3 Jul 2010 08:21:23 +0000 (09:21 +0100)
committerAndrew Flegg <andrew@bleb.org>
Sat, 3 Jul 2010 08:21:23 +0000 (09:21 +0100)
package/src/org/maemo/hermes/engine/twitter/service.py
package/test/unit/test_twitter.py

index 102acd9..58d76a0 100644 (file)
@@ -117,5 +117,6 @@ 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)
+        if friend in self._friends:
+            self._friends.remove(friend)
 
index bd38307..fdd6b25 100644 (file)
@@ -104,6 +104,26 @@ class TestTwitterService(unittest.TestCase):
         assert screen_name == matchers[contact].get_nickname()
         assert contact == matchers[contact]['contact']
         assert contact == self.testee._get_friend_by_contact(contact)['contact']
+
+
+    def test_duplicate_match_avoids_exception(self):
+        twitter_name = "Twitter Name"
+        screen_name = "tweeter"
+        tweeter = FakeTweeter(twitter_name, screen_name)
+        self._fake_server([tweeter])
+        first_contact = FakeContact("One name", ["http://twitter.com/" + screen_name])
+        second_contact = FakeContact("Other name", ["http://twitter.com/" + screen_name])
+        
+        self._exercise_service([first_contact, second_contact])
+        
+        assert len(self.testee.get_unmatched_friends()) == 0
+        matchers = self.testee.get_contacts_with_match()
+        assert first_contact in matchers
+        assert second_contact in matchers
+        assert second_contact == matchers[first_contact]['contact']
+        assert second_contact == matchers[second_contact]['contact']
+        assert second_contact == self.testee._get_friend_by_contact(first_contact)['contact']
+        assert second_contact == self.testee._get_friend_by_contact(second_contact)['contact']
         
 
     def _exercise_service(self, contacts):

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment