-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_test.py
54 lines (38 loc) · 1.22 KB
/
user_test.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
import unittest
from user_class import User
class TestUser(unittest.TestCase):
'''
Test class that checks the behaviours of the User class.
'''
def setUp(self):
self.new_user = User("michael","password") # create user object
def test_init(self):
self.assertEqual(self.new_user.username,"michael")
self.assertEqual(self.new_user.password,"password")
def test_save_user(self):
self.new_user.save_user()
self.assertEqual(len(User.user_list),1)
def tearDown(self):
'''
this will clean up after each test run.
'''
User.user_list = []
def test_save_multiple_user(self):
'''
check if we can hold multiple user accounts
'''
self.new_user.save_user()
test_user = User("andrew","password")
test_user.save_user()
self.assertEqual(len(User.user_list),2)
def test_delete_user(self):
'''
test_delete_user to test if we can remove a user from our user list
'''
self.new_user.save_user()
test_user = User("michael", "password")
test_user.save_user()
self.new_user.delete_user()
self.assertEqual(len(User.user_list),1)
if __name__ == '__main__':
unittest.main()