mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-02 17:48:36 -04:00
clean up remaining todays()
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import uuid
|
import uuid
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from sqlalchemy import Float, cast
|
from sqlalchemy import Float, cast
|
||||||
@@ -387,7 +387,7 @@ def delete_service_and_all_associated_db_objects(service):
|
|||||||
|
|
||||||
|
|
||||||
def dao_fetch_todays_stats_for_service(service_id):
|
def dao_fetch_todays_stats_for_service(service_id):
|
||||||
today = date.today()
|
today = datetime.utcnow().date()
|
||||||
start_date = get_midnight_in_utc(today)
|
start_date = get_midnight_in_utc(today)
|
||||||
return db.session.query(
|
return db.session.query(
|
||||||
Notification.notification_type,
|
Notification.notification_type,
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ def test_create_nightly_notification_status_for_service_and_day(notify_db_sessio
|
|||||||
second_service = create_service(service_name='second Service')
|
second_service = create_service(service_name='second Service')
|
||||||
second_template = create_template(service=second_service, template_type='email')
|
second_template = create_template(service=second_service, template_type='email')
|
||||||
|
|
||||||
process_day = date.today() - timedelta(days=5)
|
process_day = datetime.utcnow().date() - timedelta(days=5)
|
||||||
with freeze_time(datetime.combine(process_day, time.max)):
|
with freeze_time(datetime.combine(process_day, time.max)):
|
||||||
create_notification(template=first_template, status='delivered')
|
create_notification(template=first_template, status='delivered')
|
||||||
create_notification(template=second_template, status='temporary-failure')
|
create_notification(template=second_template, status='temporary-failure')
|
||||||
@@ -441,7 +441,7 @@ def test_create_nightly_notification_status_for_service_and_day(notify_db_sessio
|
|||||||
create_notification_history(template=second_template, status='delivered')
|
create_notification_history(template=second_template, status='delivered')
|
||||||
|
|
||||||
# these created notifications from a different day get ignored
|
# these created notifications from a different day get ignored
|
||||||
with freeze_time(datetime.combine(date.today() - timedelta(days=4), time.max)):
|
with freeze_time(datetime.combine(datetime.utcnow().date() - timedelta(days=4), time.max)):
|
||||||
create_notification(template=first_template)
|
create_notification(template=first_template)
|
||||||
create_notification_history(template=second_template)
|
create_notification_history(template=second_template)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
from datetime import date
|
from datetime import date, datetime
|
||||||
|
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
@@ -74,7 +74,7 @@ def test_get_complaint_sets_start_and_end_date_to_today_if_not_specified(mocker,
|
|||||||
dao_mock = mocker.patch('app.complaint.complaint_rest.fetch_count_of_complaints', return_value=5)
|
dao_mock = mocker.patch('app.complaint.complaint_rest.fetch_count_of_complaints', return_value=5)
|
||||||
response = client.get(url_for('complaint.get_complaint_count'), headers=[create_admin_authorization_header()])
|
response = client.get(url_for('complaint.get_complaint_count'), headers=[create_admin_authorization_header()])
|
||||||
|
|
||||||
dao_mock.assert_called_once_with(start_date=date.today(), end_date=date.today())
|
dao_mock.assert_called_once_with(start_date=datetime.utcnow().date(), end_date=datetime.utcnow().date())
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert json.loads(response.get_data(as_text=True)) == 5
|
assert json.loads(response.get_data(as_text=True)) == 5
|
||||||
|
|
||||||
|
|||||||
@@ -714,7 +714,7 @@ def test_fetch_usage_year_for_organisation_only_queries_present_year(notify_db_s
|
|||||||
last_year = current_year - 1
|
last_year = current_year - 1
|
||||||
date_two_years_ago = date(2021, 3, 31)
|
date_two_years_ago = date(2021, 3, 31)
|
||||||
date_in_last_financial_year = date(2022, 3, 31)
|
date_in_last_financial_year = date(2022, 3, 31)
|
||||||
date_in_this_year = date.today()
|
date_in_this_year = datetime.utcnow().date()
|
||||||
|
|
||||||
org = create_organisation(name='Organisation 1')
|
org = create_organisation(name='Organisation 1')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user