mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
Fix sending of performance platform
The pp client converts to UTC using the convert_utc_to_bst notify util. This requires a datatime not a date, pass it a datetime, and add an assertion in an existing test. I didn't want to use the midnight conversion util in the test. Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from app import performance_platform_client
|
from app import performance_platform_client
|
||||||
from app.dao.fact_notification_status_dao import get_total_sent_notifications_for_day_and_type
|
from app.dao.fact_notification_status_dao import get_total_sent_notifications_for_day_and_type
|
||||||
|
from app.utils import get_london_midnight_in_utc
|
||||||
|
|
||||||
|
|
||||||
def send_total_notifications_sent_for_day_stats(date, notification_type, count):
|
def send_total_notifications_sent_for_day_stats(date, notification_type, count):
|
||||||
@@ -19,8 +20,10 @@ def get_total_sent_notifications_for_day(day):
|
|||||||
sms_count = get_total_sent_notifications_for_day_and_type(day, 'sms')
|
sms_count = get_total_sent_notifications_for_day_and_type(day, 'sms')
|
||||||
letter_count = get_total_sent_notifications_for_day_and_type(day, 'letter')
|
letter_count = get_total_sent_notifications_for_day_and_type(day, 'letter')
|
||||||
|
|
||||||
|
start_date = get_london_midnight_in_utc(day)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"start_date": day,
|
"start_date": start_date,
|
||||||
"email": {
|
"email": {
|
||||||
"count": email_count
|
"count": email_count
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -53,15 +53,11 @@ def test_get_total_sent_notifications_yesterday_returns_expected_totals_dict(sam
|
|||||||
|
|
||||||
total_count_dict = get_total_sent_notifications_for_day(yesterday)
|
total_count_dict = get_total_sent_notifications_for_day(yesterday)
|
||||||
|
|
||||||
assert total_count_dict == {
|
assert total_count_dict["email"] == {"count": 3}
|
||||||
"start_date": yesterday,
|
assert total_count_dict["sms"] == {"count": 2}
|
||||||
"email": {
|
assert total_count_dict["letter"] == {"count": 1}
|
||||||
"count": 3
|
|
||||||
},
|
# Should return a time around midnight depending on timezones
|
||||||
"sms": {
|
expected_start = datetime.combine(yesterday, datetime.min.time())
|
||||||
"count": 2
|
time_diff = abs(expected_start - total_count_dict["start_date"])
|
||||||
},
|
assert time_diff <= timedelta(minutes=60)
|
||||||
"letter": {
|
|
||||||
"count": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user