Use BST to calculate monthly billing

This commit is contained in:
Rebecca Law
2017-07-25 17:38:53 +01:00
parent 3d3703750c
commit b62ee8380c
2 changed files with 13 additions and 10 deletions

View File

@@ -17,14 +17,15 @@ def test_get_april_fools():
assert april_fools.tzinfo is None
@pytest.mark.parametrize("month, year, expected_end",
[(7, 2017, 31),
(2, 2016, 29),
(2, 2017, 28),
(9, 2018, 30),
(12, 2019, 31)])
def test_get_month_start_end_date(month, year, expected_end):
@pytest.mark.parametrize("month, year, expected_start, expected_end",
[
(7, 2017, datetime(2017, 6, 30, 23, 00, 00), datetime(2017, 7, 31, 22, 59, 59, 99999)),
(2, 2016, datetime(2016, 2, 1, 00, 00, 00), datetime(2016, 2, 29, 23, 59, 59, 99999)),
(2, 2017, datetime(2017, 2, 1, 00, 00, 00), datetime(2017, 2, 28, 23, 59, 59, 99999)),
(9, 2018, datetime(2018, 8, 31, 23, 00, 00), datetime(2018, 9, 30, 22, 59, 59, 99999)),
(12, 2019, datetime(2019, 12, 1, 00, 00, 00), datetime(2019, 12, 31, 23, 59, 59, 99999))])
def test_get_month_start_end_date(month, year, expected_start, expected_end):
month_year = datetime(year, month, 10, 13, 30, 00)
result = get_month_start_end_date(month_year)
assert result[0] == datetime(year, month, 1, 0, 0, 0, 0)
assert result[1] == datetime(year, month, expected_end, 23, 59, 59, 99999)
assert result[0] == expected_start
assert result[1] == expected_end