-
Notifications
You must be signed in to change notification settings - Fork 2
/
LegacyCalculator_test.py
49 lines (37 loc) · 1.1 KB
/
LegacyCalculator_test.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
from datetime import datetime
import unittest
from LegacyCalculator import LegacyCalculator
class LegacyCalculator_test(unittest.TestCase):
def test_empty(self):
# arrange
calculator = LegacyCalculator()
# act
result = calculator.calculate([])
# assert
self.assertEqual(datetime.min, result.startTime)
def test_withOneDate(self):
# arrange
calculator = LegacyCalculator()
dates = [ datetime.now() ]
# act
result = calculator.calculate(dates)
# assert
self.assertEqual(datetime.min, result.startTime)
self.assertEqual(0, result.count)
def test_withManyDates(self):
# arrange
calculator = LegacyCalculator()
dates = [
datetime(2018, 1, 1),
datetime(2018, 1, 2),
datetime(2018, 1, 10),
datetime(2018, 1, 11),
datetime(2018, 1, 12),
]
# act
result = calculator.calculate(dates)
# assert
self.assertEqual(datetime(2018, 1, 8), result.startTime)
self.assertEqual(3, result.count)
if __name__ == '__main__':
unittest.main()