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:
Leo Hemsted
2019-08-30 17:16:43 +01:00
parent 5975ae2383
commit 93e631221a
4 changed files with 12 additions and 9 deletions

View File

@@ -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