mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
use dates rather than datetimes when comparing with bst_date
bst_date is a date field. Comparing dates with datetimes in postgres gets confusing and dangerous. See this example, where a date evaluates as older than midnight that same day. ``` notification_api=# select '2019-04-01' >= '2019-04-01 00:00'; ?column? ---------- f (1 row) ``` By only using dates everywhere, we reduce the chance of these bugs happening
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -40,7 +40,8 @@ def test_get_month_start_and_end_date_in_utc(month, year, expected_start, expect
|
||||
(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),
|
||||
(date(2019, 3, 31), 2018),
|
||||
(date(2019, 4, 1), 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