-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_employee2.py
More file actions
executable file
·73 lines (53 loc) · 2.24 KB
/
test_employee2.py
File metadata and controls
executable file
·73 lines (53 loc) · 2.24 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
from employee import Employee
import unittest
#unit test with print statement , that shows test does not run in order ,
class TestEmployee(unittest.TestCase):
#this will run once before every test
@classmethod
def setUpClass(cls):
print('setupClass')
#This will run once after evry test
@classmethod
def tearDownClass(cls):
print('teardownClass')
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, 'Corey.Schafer@email.com')
self.assertEqual(self.emp_2.email, 'Sue.Smith@email.com')
self.emp_1.first = 'John'
self.emp_2.first = 'Jane'
self.assertEqual(self.emp_1.email, 'John.Schafer@email.com')
self.assertEqual(self.emp_2.email, 'Jane.Smith@email.com')
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)
# def test_monthly_schedule(self):
# with patch('employee.requests.get') as mocked_get:
# mocked_get.return_value.ok = True
# mocked_get.return_value.text = 'Success'
# schedule = self.emp_1.monthly_schedule('May')
# mocked_get.assert_called_with('http://company.com/Schafer/May')
# self.assertEqual(schedule, 'Success')
# mocked_get.return_value.ok = False
# schedule = self.emp_2.monthly_schedule('June')
# mocked_get.assert_called_with('http://company.com/Smith/June')
# self.assertEqual(schedule, 'Bad Response!')
if __name__ == '__main__':
unittest.main()