Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
e677dfa8efc9c84af8ce7828555037c72bce9022
1 import unittest
2 from syncjob import Syncjob
4 class FakeContact():
5     def __init__(self, name, addr):
6         self.name = name
7         self.urls = [addr]
8     def get_emails(self):
9         return self.urls
10     def get_name(self):
11         return self.name
12     
13 class FakeService():
14     def __init__(self):
15         self.contacts_preprocessed = []
16         self.contacts_processed = []
17     def get_name(self):
18         return "fake service"
19     def pre_process_contact(self, contact):
20         self.contacts_preprocessed.append(contact)
21     def process_friends(self):
22         pass
23     def process_contact(self, contact):
24         self.contacts_processed.append(contact)
25      
26     
27 class TestSyncJob(unittest.TestCase):
28     
29     def setUp(self):
30         self.service = FakeService() 
31         self.services = [self.service]
32         self.contact = FakeContact('Fredrik Wendt', 'fredrik@wendt.se')
33         self.contacts = [self.contact]
34         self.testee = Syncjob(self.services, self.contacts)
35         
36     def test_main_flow(self):
37         self.testee.run()
38         assert self.contact in self.service.contacts_preprocessed
39         assert self.contact in self.service.contacts_processed
40     
41 if __name__ == '__main__':
42     unittest.main()

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment