mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
rename which_financial_year to get_financial_year_for_datetime
also fix bug on the very second of rollover, march 31st 23:00:00, and add tests
This commit is contained in:
@@ -2,7 +2,12 @@ from datetime import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from app.dao.date_util import get_financial_year, get_april_fools, get_month_start_and_end_date_in_utc
|
||||
from app.dao.date_util import (
|
||||
get_financial_year,
|
||||
get_april_fools,
|
||||
get_month_start_and_end_date_in_utc,
|
||||
get_financial_year_for_datetime,
|
||||
)
|
||||
|
||||
|
||||
def test_get_financial_year():
|
||||
@@ -29,3 +34,13 @@ def test_get_month_start_and_end_date_in_utc(month, year, expected_start, expect
|
||||
result = get_month_start_and_end_date_in_utc(month_year)
|
||||
assert result[0] == expected_start
|
||||
assert result[1] == expected_end
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dt, fy", [
|
||||
(datetime(2018, 3, 31, 23, 0, 0), 2018),
|
||||
(datetime(2019, 3, 31, 22, 59, 59), 2018),
|
||||
(datetime(2019, 3, 31, 23, 0, 0), 2019),
|
||||
(datetime(2020, 3, 31, 22, 59, 0), 2019),
|
||||
])
|
||||
def test_get_financial_year_for_datetime(dt, fy):
|
||||
assert get_financial_year_for_datetime(dt) == fy
|
||||
|
||||
Reference in New Issue
Block a user