Repository navigation
Expand file tree
/
Copy pathcredentials_class.py
More file actions
executable file
·108 lines (94 loc) · 3.26 KB
/
Copy pathcredentials_class.py
File metadata and controls
executable file
·108 lines (94 loc) · 3.26 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
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
102
103
104
105
106
107
108
import unittest
import pyperclip
from user_class import Credentials
from user_class import User
# sub-class
class UserTest(unittest.TestCase):
def setUp(self):
'''
method run before each user test
'''
self.new_user = User("James", "Doe")
def tearDown(self):
'''
method called after each user test
'''
User.data_user = []
def test_init(self):
'''
test method to check if user class is initialized correctly
'''
self.assertTrue(self.new_user.owner,"James")
self.assertTrue(self.new_user.key, "Doe")
def test_save_user():
'''
test method to test if user has been saved into class list
'''
self.new_user.save_user()
self.assertEqual(len(User.data_user),1)
class User_classTest(unittest.TestCase):
def setUp(self):
'''
method run before each test
'''
self.new_account = Credentials("instagram","Mary","myPassword")
def tearDown(self):
'''
method run fter each test
'''
Credentials.account_credentials = []
def test_init(self):
'''
test to check for proper initialization
'''
self.assertEqual(self.new_account_name,"instagram")
self.assertEqual(self.new_account.username,"Mary")
self.assertEqual(self.new_account.password,"myPassword")
def test_save_account(self):
'''
test method that checks if account has been saved
'''
self.new_account.save_account()
self.assertEqual(len(Credentials.account_credentials),1)
def test_save_multiple(self):
'''
test method to check if user can add many accounts
'''
self.new_account.save_account()
another_account = Credentials("Twitter", "Edu", "Kenya@123")
another_account.save_account()
self.assertEqual(len(Credentials.account_credentials),2)
def test_delete_account(self):
'''
test method to check if an account has been deleted
'''
self.new_account.save_account()
another_account = Credentials("Twitter", "Edu", "Morgan")
another_account.save_account()
self.new_account.delete_account()
self.assertEqual(len(Credentials.account_credentials),1)
def test_password_autogenerate(self):
'''
test method to test auto generation of passwords
'''
self.new_account.save_account()
another_account = Credentials("Twitter", "Edu")
another_account.save_account()
def test_display_accounts(self):
'''
test method to check displaying of accounts
'''
self.new_account.save_account()
another_account = Credentials("Twitter","Chris", "Mulili")
another_account.save_account()
self.assertEqual(Credentials.display_accounts(), Credentials.display_accounts)
def test_search_accounts(self):
'''
test method to test search functionality
'''
self.new_account.save_account()
another_account =Credentials("Twitter", "Edu", "Kenya@123")
another_account.save_account()
self.assertEqual(another_account,Credentials.search_accounts("Twitter"))
if __name__ == '__main__':
unittest.main