-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeTest.py
37 lines (28 loc) · 1.05 KB
/
TimeTest.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
import unittest
from Time import Time
from Hours import Hours
class TimeTest(unittest.TestCase):
def test_can_specify_simple_time(self):
time = Time(7)
self.assertEquals(time.get_hour(), 7)
def test_can_specify_minute(self):
time = Time(10, 30)
self.assertEquals(time.get_minute(), 30)
def test_can_calculate_time_distance(self):
t1 = Time(7)
t2 = Time(8)
self.assertEquals(t1.distance_to(t2), Hours(1))
def test_can_calculate_time_distance_for_half_hour(self):
t1 = Time(7)
t2 = Time(7, 30)
self.assertEquals(t1.distance_to(t2), Hours(0, 30))
def test_can_be_compared_for_equality(self):
self.assertEquals(Time(7), Time(7))
def test_can_be_moved_by_hours(self):
self.assertEquals(Time(7).add_hours(Hours(10)), Time(17))
def test_can_be_printed(self):
self.assertEquals(str(Time(7)), "7:00")
def test_can_be_compared_with_other_time(self):
self.assertTrue(Time(20) > Time(19))
if __name__ == "__main__":
unittest.main()