Dependency inject service ID, so that it can be stamped on friends and
[hermes] / package / test / unit / test_linkedin.py
index cd337a5..5f6f4c0 100644 (file)
@@ -33,7 +33,30 @@ class TestLinkedInService(unittest.TestCase):
     
     def setUp(self):
         self.linkedInApi = FakeLinkedInApi()
-        self.testee = Service(self.linkedInApi)
+        self.testee = Service('linkedin', self.linkedInApi)
+
+
+    def test_that_process_contact_returns_None_for_unknown_contact(self):
+        contact = FakeContact('Person Person', [])
+        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_process_contact_returns_friend_object_if_contact_is_known(self):
+        same_name = "A Name"
+        contact = FakeContact(same_name, [])
+        fake_friend = Friend(same_name)
+        self._fake_server_response([fake_friend])
+        
+        self.testee.pre_process_contact(contact);
+        self.testee.process_friends()
+        friend = self.testee.process_contact(contact)
+        assert isinstance(friend, Friend)
+
         
     def test_main_flow_one_match_by_url_one_by_name(self):
         known_url = "http://linkedin/id=1"
@@ -53,6 +76,9 @@ class TestLinkedInService(unittest.TestCase):
         assert contact_by_name in matchers
         assert contact_by_url in matchers
         assert known_url in matchers[contact_by_url].get_urls()
+        assert contact_by_url == matchers[contact_by_url].get_contact()
+        assert contact_by_name == matchers[contact_by_name].get_contact()
+
         
     def _run_service(self, contacts):
         for contact in contacts: