-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_all.py
39 lines (27 loc) · 1.18 KB
/
test_all.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
import work_percent
from freezegun import freeze_time
from datetime import datetime
@freeze_time("13:00:00")
def test_basic_percent_calculation():
""" If your work day is between 9am and 5pm, make sure that at 1pm it displays 50% """
_test_half_way_between_range(9, 17)
@freeze_time("01:00:00")
def test_percent_calculation_when_range_crosses_midnight():
""" Now if your work day starts late at night (10pm), make sure it can cross midnight if you work till 4am """
_test_half_way_between_range(22, 4)
@freeze_time("12:00:00")
def test_full_day_percent():
""" Test a full day from 0am to 0am which should be half done at noon """
_test_half_way_between_range(0, 0)
@freeze_time("00:00:00")
def test_full_day_starting_at_noon():
""" Test a full day but start from noon """
_test_half_way_between_range(12, 12)
@freeze_time("01:00:00")
def test_percent_calculation_with_floats():
""" Test that calculations work with floating point numbers """
_test_half_way_between_range(22.5, 3.5)
def _test_half_way_between_range(start, end):
workPercent = work_percent.WorkPercent(start, end, 3)
percent = workPercent.work_percent()
assert percent == 50