-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhite_box_notifs.py
95 lines (73 loc) · 2.77 KB
/
white_box_notifs.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from main import *
from Person import Person
import unittest
from construct_db import *
from unittest.mock import patch
class Current():
def __init__(self) -> None:
Session = sessionmaker(bind=engine)
self.session = Session()
self.user = None
class TestStringMethods(unittest.TestCase):
cur = Current()
@patch('main.InputHandler.Handler')
def test_notifs_1(self, mock_handler):
'''
White box test case 1
'''
#setup
# create inviter
username1 = "pineapple1"
password = "fruitiness"
inviter = Person(self.cur.session, username1, password, "signup")
# create project to invite to
project_id = inviter.create_project("Pineapple project", "pineapples work on this")
# create 2nd user
username2 = "pineapple2"
self.cur.user = Person(self.cur.session, username2, password, "signup")
# invite 2nd user
inviter.invite_member(username2, project_id=project_id)
mock_handler.return_value = "1"
result = notifications(self.cur)
assert result == "HOME"
@patch('main.InputHandler.Handler')
def test_notifs_2(self, mock_handler):
'''
White box test case 2
'''
# create inviter
username1 = "orange1"
password = "fruitiness"
inviter = Person(self.cur.session, username1, password, "signup")
# create project to invite to
task_id = inviter.create_task("Orange task", "oranges work on this", 6)
# create 2nd user
username2 = "oranges2"
self.cur.user = Person(self.cur.session, username2, password, "signup")
# invite 2nd user
inviter.invite_member(username2, task_id=task_id)
mock_handler.return_value = "1"
result = notifications(self.cur)
assert result == "HOME"
@patch('main.InputHandler.Handler')
def test_notifs_3(self, mock_handler):
'''
White box test case 3
'''
#setup
# create inviter
username1 = "grape1"
password = "fruitiness"
inviter = Person(self.cur.session, username1, password, "signup")
# create project to invite to
project_id = inviter.create_project("Grape project", "grapes work on this")
# create 2nd user
username2 = "grape2"
self.cur.user = Person(self.cur.session, username2, password, "signup")
# invite 2nd user
inviter.invite_member(username2, project_id=project_id)
mock_handler.return_value = "2"
result = notifications(self.cur)
assert result == "HOME"
if __name__ == '__main__':
unittest.main()