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 21:39:01 +0000 (22:39 +0100)
committerFredrik Wendt <fredrik@wendt.se>
Tue, 8 Jun 2010 21:39:01 +0000 (22:39 +0100)
Signed-off-by: Fredrik Wendt <fredrik@wendt.se>

package/src/org/maemo/hermes/engine/gravatar/service.py
package/test/unit/test_gravatar.py

index 364d679..24132cb 100644 (file)
@@ -55,6 +55,9 @@ class Service(org.maemo.hermes.engine.service.Service):
                     friend = self._create_friend(contact.get_name())
                     friend.set_photo_url(self._get_url_for_email_hash(hash))
                     self._register_match(contact, friend)
                     friend = self._create_friend(contact.get_name())
                     friend.set_photo_url(self._get_url_for_email_hash(hash))
                     self._register_match(contact, friend)
+                    return friend
+        
+        return None
 
 
     # -----------------------------------------------------------------------
 
 
     # -----------------------------------------------------------------------
index f2e5141..3de6b32 100644 (file)
@@ -9,12 +9,35 @@ class FakeContact():
         return self.urls
     def get_name(self):
         return self.urls[0]
         return self.urls
     def get_name(self):
         return self.urls[0]
+
+known_address = "maemohermes@wendt.se"
     
 class TestGravatarService(unittest.TestCase):
     
     def setUp(self):
         self._setUp('', '')
         
     
 class TestGravatarService(unittest.TestCase):
     
     def setUp(self):
         self._setUp('', '')
         
+        
+    def test_that_process_contact_returns_friend_object_if_contact_is_known(self):
+        contact = FakeContact([known_address])
+        self._fake_server_response({known_address: 'http://image.exists.here/'})
+        
+        self.testee.pre_process_contact(contact);
+        self.testee.process_friends()
+        friend = self.testee.process_contact(contact)
+        assert isinstance(friend, Friend)
+        
+        
+    def test_that_process_contact_returns_None_for_unknown_contact(self):
+        contact = FakeContact([known_address])
+        self._fake_server_response({})
+        
+        self.testee.pre_process_contact(contact);
+        self.testee.process_friends()
+        friend = self.testee.process_contact(contact)
+        assert friend is None
+        
+        
     def test_that_a_person_with_two_addresses_and_one_gravatar_works(self):
         self._fake_server_response({self.missing_address: None,
                                     self.existing_address: "http://url.to.img/"})
     def test_that_a_person_with_two_addresses_and_one_gravatar_works(self):
         self._fake_server_response({self.missing_address: None,
                                     self.existing_address: "http://url.to.img/"})

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment