-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_unittest.py
101 lines (67 loc) · 2.8 KB
/
test_unittest.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
96
97
98
99
100
101
# This file performs unit tests on important functions
# The main code to be tested
import funcs
import ticket
# The test framework
import unittest
# Testing the authenticate function
class Test_Auth(unittest.TestCase):
# Testing invalid inputs
def test_try_bad_input(self):
# Providinig invalid inputs
user_subdomain = "not_a_subdomain"
user_email = "not_an_email"
user_pass = "not_a_password"
# Passing them to the function
authenticated, response = funcs.try_authentication(user_subdomain, user_email, user_pass)
# Return values of False and None incicate the user was not authenticated
self.assertEqual((authenticated, response), (False, None))
# Testing null inputs
def test_try_null_input(self):
# Providinig null inputs
user_subdomain = None
user_email = None
user_pass = None
# Passing them to the function
authenticated, response = funcs.try_authentication(user_subdomain, user_email, user_pass)
# Return values of False and None incicate the user was not authenticated
self.assertEqual((authenticated, response), (False, None))
# Testing the function that displays the tickets for the user in the shell
class Test_Display_Tickets(unittest.TestCase):
# Testing invalid inputs
def test_try_empty_input(self):
# Providinig invalid inputs
attribute_matrix = []
ticket_objects = []
# Calling the function and picking up any system output
check_displayed = funcs.display_tickets(attribute_matrix, ticket_objects)
# Should return False, since there are no tickets related to the users account
self.assertEqual(check_displayed, False)
# Testing null inputs
def test_try_null_input(self):
# Providinig invalid inputs
attribute_matrix = None
ticket_objects = None
# Calling the function and picking up any system output
check_displayed = funcs.display_tickets(attribute_matrix, ticket_objects)
# Should return False, since there are no tickets related to the users account
self.assertEqual(check_displayed, False)
# Testing the general flexibility of Ticket objects
class Test_Ticket_Objects(unittest.TestCase):
def test_null_attributes(self):
# Testing to see if a null object can be created
t = ticket.Ticket(
None,
None,
None,
None,
None,
None,
None
)
attributes = t.get_ticket_attributes_list()
# Should just be a list of null values
self.assertEqual(attributes, ["No value!", "No value!", "No value!", "No value!", "No value!", "No value!"])
# Running the unit tests
if __name__ == '__main__':
unittest.main()