-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_object_model.py
More file actions
56 lines (42 loc) · 1.67 KB
/
test_object_model.py
File metadata and controls
56 lines (42 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Import dummy notifs for testing
from constants import DUMMY_USER_DICT
# Factory variant creators.
from Models.ConcreteFactory import email_notif_factory, post_notif_factory, sms_notif_factory
import unittest
desc = '''
This unittest verifies instance relation.
Since the project uses Factory design pattern for object modelling,
it's important to make sure objects are rightly created and are instances
of the subclass they are supposed to be of.
'''
class TestDispatcher(unittest.TestCase):
@classmethod
def setUpClass(cls):
# Notifier client map
cls.NOTIFIER_CLIENTS = {
"sms": sms_notif_factory.SmsNotifierFactory,
"post": post_notif_factory.PostNotifierFactory,
"email": email_notif_factory.EmailNotifierFactory,
}
cls.dummy = DUMMY_USER_DICT
# Since
def test_dispatcher_object_relation(self):
testIn = TestDispatcher.dummy.get("valid_user_email").get("in")
print("Checking dispatch for EmailNotifierFactory ...")
self.assertIsInstance(
TestDispatcher.NOTIFIER_CLIENTS.get("email")(testIn),
email_notif_factory.EmailNotifierFactory,
)
print("Checking dispatch for SmsNotifierFactory ...")
self.assertIsInstance(
TestDispatcher.NOTIFIER_CLIENTS.get("sms")(testIn),
sms_notif_factory.SmsNotifierFactory,
)
print("Checking dispatch for PostNotifierFactory ...")
self.assertIsInstance(
TestDispatcher.NOTIFIER_CLIENTS.get("post")(testIn),
post_notif_factory.PostNotifierFactory,
)
if __name__ == '__main__':
print(desc)
unittest.main()