-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_module.py
68 lines (53 loc) · 3.12 KB
/
test_module.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
import unittest
from time_calculator import add_time
class UnitTests(unittest.TestCase):
def test_same_period(self):
actual = add_time("3:30 PM", "2:12")
expected = "5:42 PM"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "3:30 PM", "2:12" to return "5:42 PM"')
def test_different_period(self):
actual = add_time("11:55 AM", "3:12")
expected = "3:07 PM"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "11:55 AM", "3:12" to return "3:07 PM"')
def test_next_day(self):
actual = add_time("9:15 PM", "5:30")
expected = "2:45 AM (next day)"
self.assertEqual(actual, expected, 'Expected time to end with "(next day)" when it is the next day.')
def test_period_change_at_twelve(self):
actual = add_time("11:40 AM", "0:25")
expected = "12:05 PM"
self.assertEqual(actual, expected, 'Expected period to change from AM to PM at 12:00')
def test_twenty_four(self):
actual = add_time("2:59 AM", "24:00")
expected = "2:59 AM (next day)"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "2:59 AM", "24:00" to return "2:59 AM"')
def test_two_days_later(self):
actual = add_time("11:59 PM", "24:05")
expected = "12:04 AM (2 days later)"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "11:59 PM", "24:05" to return "12:04 AM (2 days later)"')
def test_high_duration(self):
actual = add_time("8:16 PM", "466:02")
expected = "6:18 AM (20 days later)"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "8:16 PM", "466:02" to return "6:18 AM (20 days later)"')
def test_no_change(self):
actual = add_time("5:01 AM", "0:00")
expected = "5:01 AM"
self.assertEqual(actual, expected, 'Expected adding 0:00 to return initial time.')
def test_same_period_with_day(self):
actual = add_time("3:30 PM", "2:12", "Monday")
expected = "5:42 PM, Monday"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "3:30 PM", "2:12", "Monday" to return "5:42 PM, Monday"')
def test_twenty_four_with_day(self):
actual = add_time("2:59 AM", "24:00", "saturDay")
expected = "2:59 AM, Sunday (next day)"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "2:59 AM", "24:00", "saturDay" to return "2:59 AM, Sunday (next day)"')
def test_two_days_later_with_day(self):
actual = add_time("11:59 PM", "24:05", "Wednesday")
expected = "12:04 AM, Friday (2 days later)"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "2:59 AM", "24:00", "Friday" to return "12:04 AM, Friday (2 days later)"')
def test_high_duration_with_day(self):
actual = add_time("8:16 PM", "466:02", "tuesday")
expected = "6:18 AM, Monday (20 days later)"
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "8:16 PM", "466:02", "tuesday" to return "6:18 AM, Monday (20 days later)"')
if __name__ == "__main__":
unittest.main()