Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
authorFredrik Wendt <fredrik@wendt.se>
Wed, 9 Jun 2010 10:53:03 +0000 (11:53 +0100)
committerFredrik Wendt <fredrik@wendt.se>
Wed, 9 Jun 2010 10:53:03 +0000 (11:53 +0100)
Signed-off-by: Fredrik Wendt <fredrik@wendt.se>

package/test/unit/test_facebook.py

index 93255bb..3869c58 100644 (file)
@@ -4,7 +4,6 @@ from org.maemo.hermes.engine.friend import Friend
 import unittest
 
 
-
 class FakeContact():
     id_counter = 0
     def __init__(self, name, addr, id=None):
@@ -19,13 +18,14 @@ class FakeContact():
     def get_identifiers(self):
         return [canonical(self.name)]
     
+
 class TestFacebookService(unittest.TestCase):
     
     def setUp(self):
         self.testee = Service(None)
         
         
-    def test_that_process_known_contact_returns_friend_object(self):
+    def test_that_process_contact_returns_friend_object_for_known_contact(self):
         known_url = 'http://www.facebook.com/profile.php?id=123456'
         known_contact = FakeContact('Facebook Junkie', [known_url])
         self._fake_server_response([{'uid':'123456','name':'Facebook Junkie'}])
@@ -35,6 +35,15 @@ class TestFacebookService(unittest.TestCase):
         assert isinstance(result, Friend)
 
 
+    def test_that_process_contact_returns_None_for_unknown_contact(self):
+        known_contact = FakeContact('Facebook Junkie', [])
+        self._fake_server_response([])
+        
+        self.testee.process_friends()
+        result = self.testee.process_contact(known_contact)
+        assert result is None
+
+
     def test_main_flow_one_match_by_url_one_by_name(self):
         # arrange
         self.existing_address = 'http://www.facebook.com/profile.php?id=123456'
@@ -66,10 +75,11 @@ class TestFacebookService(unittest.TestCase):
         
         
     def test_name_collision_avoided_by_previous_matching(self):
-        contact_do_match = FakeContact("Same Name", ["http://www.facebook.com/profile.php?id=123"], 1);
-        contact_no_match = FakeContact("Same Name", [None], 2)
+        name = "Same Name"
+        contact_do_match = FakeContact(name, ["http://www.facebook.com/profile.php?id=123"], 1);
+        contact_no_match = FakeContact(name, [None], 2)
         
-        data = [{'uid':'123','name':'Same Name'}]
+        data = [{'uid':'123','name':name}]
         self._fake_server_response(data)
         
         self._run_service([contact_no_match, contact_do_match])
@@ -81,10 +91,11 @@ class TestFacebookService(unittest.TestCase):
 
       
     def test_name_collision_avoided_only_one_person_matched(self):
-        contact_do_match = FakeContact("Same Name", ["http://twitter.com/same_name"]);
-        contact_no_match = FakeContact("Same Name", [None])
+        name = "Same Name"
+        contact_do_match = FakeContact(name, ["Contact 1"]);
+        contact_no_match = FakeContact(name, ["Contact 2"])
         
-        data = [{'uid':'123','name':'Same Name'}]
+        data = [{'uid':'123','name':name}]
         self._fake_server_response(data)
         
         self._run_service([contact_no_match, contact_do_match])

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment