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 16:33:13 +0000 (17:33 +0100)
committerFredrik Wendt <fredrik@wendt.se>
Tue, 8 Jun 2010 16:33:13 +0000 (17:33 +0100)
Signed-off-by: Fredrik Wendt <fredrik@wendt.se>

package/test/integration/test_gravatar.py [new file with mode: 0644]
package/test/unit/test_gravatar.py

diff --git a/package/test/integration/test_gravatar.py b/package/test/integration/test_gravatar.py
new file mode 100644 (file)
index 0000000..7d2617e
--- /dev/null
@@ -0,0 +1,49 @@
+from org.maemo.hermes.engine.gravatar.service import Service
+from org.maemo.hermes.engine.friend import Friend 
+import unittest
+
+class FakeContact():
+    def __init__(self, addr):
+        self.urls = addr
+    def get_emails(self):
+        return self.urls
+    def get_name(self):
+        return self.urls[0]
+    
+class TestGravatarService(unittest.TestCase):
+    
+    def setUp(self):
+        self.testee = Service('maemohermes@wendt.se', 'b14ec179822b')
+        
+        self.existing_address = 'fredrik@wendt.se'
+        self.existing_contact = FakeContact([self.existing_address])
+        self.existing_friend = Friend("Fredrik Wendt")
+        
+        self.missing_address = 'will_not_ever_exist_i_truly_hope_at_least@wendt.se'
+        self.missing_contact = FakeContact([self.missing_address])
+        self.missing_friend = Friend("Unknown Person")
+        
+        self.multiple_contact = FakeContact([self.existing_address, self.missing_address])
+        self.multiple_friend = Friend("Another Person")
+        
+        
+    def test_main_flow(self):
+        self.testee.pre_process_contact(self.existing_contact)
+        self.testee.pre_process_contact(self.missing_contact)
+        self.testee.process_friends()
+        self.testee.process_contact(self.existing_contact)
+        self.testee.process_contact(self.missing_contact)
+        
+        friends = self.testee.get_friends()
+        contacts = self.testee.get_contacts_with_match()
+        assert len(friends) == 1
+        assert len(contacts) == 1
+        assert self.missing_contact not in contacts.keys()
+        assert self.existing_contact in contacts.keys()
+        friend = friends[0]
+        assert friend.get_name() == self.existing_contact.get_name()
+
+
+    
+if __name__ == '__main__':
+    unittest.main()
index 077145b..eab4873 100644 (file)
@@ -15,26 +15,9 @@ class TestGravatarService(unittest.TestCase):
     def setUp(self):
         self._setUp('maemohermes@wendt.se', 'b14ec179822b')
         
-    def test_main_flow(self):
-        self.testee.pre_process_contact(self.existing_contact)
-        self.testee.pre_process_contact(self.missing_contact)
-        self.testee.process_friends()
-        self.testee.process_contact(self.existing_contact)
-        self.testee.process_contact(self.missing_contact)
-        
-        friends = self.testee.get_friends()
-        contacts = self.testee.get_contacts_with_match()
-        assert len(friends) == 1
-        assert len(contacts) == 1
-        assert self.missing_contact not in contacts.keys()
-        assert self.existing_contact in contacts.keys()
-        friend = friends[0]
-        assert friend.get_name() == self.existing_contact.get_name()
-        print friend.get_photo_url()
-        
-        
     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/"})
+        self._fake_server_response({self.missing_address: None,
+                                    self.existing_address: "http://url.to.img/"})
         
         self.testee.pre_process_contact(self.multiple_contact)
         self.testee.process_friends()

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment