mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Removing instances of a financial year
This commit is contained in:
@@ -9,9 +9,8 @@ from app.utils.csv import get_user_preferred_timezone
|
|||||||
def get_current_financial_year():
|
def get_current_financial_year():
|
||||||
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
preferred_tz = pytz.timezone(get_user_preferred_timezone())
|
||||||
now = datetime.now(preferred_tz)
|
now = datetime.now(preferred_tz)
|
||||||
current_month = int(now.strftime("%-m"))
|
|
||||||
current_year = int(now.strftime("%Y"))
|
current_year = int(now.strftime("%Y"))
|
||||||
return current_year if current_month < 10 else current_year + 1
|
return current_year
|
||||||
|
|
||||||
|
|
||||||
def is_less_than_days_ago(date_from_db, number_of_days):
|
def is_less_than_days_ago(date_from_db, number_of_days):
|
||||||
|
|||||||
@@ -15,17 +15,3 @@ from app.utils.time import get_current_financial_year, is_less_than_days_ago
|
|||||||
@freeze_time("2020-02-14T12:00:00")
|
@freeze_time("2020-02-14T12:00:00")
|
||||||
def test_is_less_than_days_ago(date_from_db, expected_result):
|
def test_is_less_than_days_ago(date_from_db, expected_result):
|
||||||
assert is_less_than_days_ago(date_from_db, 90) == expected_result
|
assert is_less_than_days_ago(date_from_db, 90) == expected_result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
("datetime_string", "financial_year"),
|
|
||||||
[
|
|
||||||
("2021-01-01T00:00:00+00:00", 2021), # Start of 2021
|
|
||||||
("2021-04-01T03:59:59+00:00", 2021), # One minute before midnight (BST)
|
|
||||||
("2021-10-01T04:05:00+00:00", 2022), # Midnight (BST)
|
|
||||||
("2021-12-12T12:12:12+01:00", 2022), # Later in the year
|
|
||||||
],
|
|
||||||
)
|
|
||||||
def test_get_financial_year(datetime_string, financial_year):
|
|
||||||
with freeze_time(datetime_string):
|
|
||||||
assert get_current_financial_year() == financial_year
|
|
||||||
|
|||||||
Reference in New Issue
Block a user