-
Notifications
You must be signed in to change notification settings - Fork 17.5k
/
Copy pathsnippets.txt
124 lines (87 loc) · 3.25 KB
/
snippets.txt
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import unittest
from employee import Employee
class TestEmployee(unittest.TestCase):
def test_email(self):
emp_1 = Employee('Corey', 'Schafer', 50000)
emp_2 = Employee('Sue', 'Smith', 60000)
self.assertEqual(emp_1.email, '[email protected]')
self.assertEqual(emp_2.email, '[email protected]')
emp_1.first = 'John'
emp_2.first = 'Jane'
self.assertEqual(emp_1.email, '[email protected]')
self.assertEqual(emp_2.email, '[email protected]')
def test_fullname(self):
emp_1 = Employee('Corey', 'Schafer', 50000)
emp_2 = Employee('Sue', 'Smith', 60000)
self.assertEqual(emp_1.fullname, 'Corey Schafer')
self.assertEqual(emp_2.fullname, 'Sue Smith')
emp_1.first = 'John'
emp_2.first = 'Jane'
self.assertEqual(emp_1.fullname, 'John Schafer')
self.assertEqual(emp_2.fullname, 'Jane Smith')
def test_apply_raise(self):
emp_1 = Employee('Corey', 'Schafer', 50000)
emp_2 = Employee('Sue', 'Smith', 60000)
emp_1.apply_raise()
emp_2.apply_raise()
self.assertEqual(emp_1.pay, 52500)
self.assertEqual(emp_2.pay, 63000)
if __name__ == '__main__':
unittest.main()
###### With Prints ######
import unittest
from employee import Employee
class TestEmployee(unittest.TestCase):
def setUp(self):
print('setUp')
self.emp_1 = Employee('Corey', 'Schafer', 50000)
self.emp_2 = Employee('Sue', 'Smith', 60000)
def tearDown(self):
print('tearDown\n')
def test_email(self):
print('test_email')
self.assertEqual(self.emp_1.email, '[email protected]')
self.assertEqual(self.emp_2.email, '[email protected]')
self.emp_1.first = 'John'
self.emp_2.first = 'Jane'
self.assertEqual(self.emp_1.email, '[email protected]')
self.assertEqual(self.emp_2.email, '[email protected]')
def test_fullname(self):
print('test_fullname')
self.assertEqual(self.emp_1.fullname, 'Corey Schafer')
self.assertEqual(self.emp_2.fullname, 'Sue Smith')
self.emp_1.first = 'John'
self.emp_2.first = 'Jane'
self.assertEqual(self.emp_1.fullname, 'John Schafer')
self.assertEqual(self.emp_2.fullname, 'Jane Smith')
def test_apply_raise(self):
print('test_apply_raise')
self.emp_1.apply_raise()
self.emp_2.apply_raise()
self.assertEqual(self.emp_1.pay, 52500)
self.assertEqual(self.emp_2.pay, 63000)
if __name__ == '__main__':
unittest.main()
###### setUpClass and tearDownClass ######
@classmethod
def setUpClass(cls):
print('setupClass')
@classmethod
def tearDownClass(cls):
print('teardownClass')
##### Mocking #####
def monthly_schedule(self, month):
response = requests.get(f'http://company.com/{self.last}/{month}')
if response.ok:
return response.text
else:
return 'Bad Response!'
else:
return 'OK'
^^*#comment below the reason for bad response and fix the problem
#def_monthly else return "Bad Response"
#Code Compiled and Completed through & through
#Code is Bilateral and forgone to wits
else
return "Good Response"
)}] #codecompleted