mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-31 11:28:30 -04:00
notify-281 fix time-sensitive tests
This commit is contained in:
@@ -404,10 +404,11 @@ def dao_fetch_todays_stats_for_service(service_id):
|
||||
|
||||
|
||||
def dao_fetch_todays_stats_for_all_services(include_from_test_key=True, only_active=True):
|
||||
today = date.today()
|
||||
today = datetime.utcnow().date()
|
||||
start_date = get_midnight_in_utc(today)
|
||||
end_date = get_midnight_in_utc(today + timedelta(days=1))
|
||||
|
||||
|
||||
subquery = db.session.query(
|
||||
Notification.notification_type,
|
||||
Notification.status,
|
||||
|
||||
@@ -527,7 +527,6 @@ def get_detailed_services(start_date, end_date, only_active=False, include_from_
|
||||
stats = dao_fetch_todays_stats_for_all_services(include_from_test_key=include_from_test_key,
|
||||
only_active=only_active)
|
||||
else:
|
||||
|
||||
stats = fetch_stats_for_all_services_by_date_range(start_date=start_date,
|
||||
end_date=end_date,
|
||||
include_from_test_key=include_from_test_key,
|
||||
|
||||
@@ -495,7 +495,7 @@ def test_create_nightly_notification_status_for_service_and_day(notify_db_sessio
|
||||
def test_create_nightly_notification_status_for_service_and_day_overwrites_old_data(notify_db_session):
|
||||
first_service = create_service(service_name='First Service')
|
||||
first_template = create_template(service=first_service)
|
||||
process_day = date.today()
|
||||
process_day = datetime.utcnow().date()
|
||||
|
||||
# first run: one notification, expect one row (just one status)
|
||||
notification = create_notification(template=first_template, status='sending')
|
||||
|
||||
@@ -297,7 +297,6 @@ def create_notification(
|
||||
}
|
||||
notification = Notification(**data)
|
||||
dao_create_notification(notification)
|
||||
|
||||
return notification
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import json
|
||||
from datetime import date, datetime
|
||||
from datetime import datetime
|
||||
|
||||
from flask import url_for
|
||||
|
||||
@@ -27,7 +27,8 @@ def test_template_history_version(notify_api, sample_user, sample_template):
|
||||
assert json_resp['data']['version'] == 1
|
||||
assert json_resp['data']['process_type'] == 'normal'
|
||||
assert json_resp['data']['created_by']['name'] == sample_user.name
|
||||
assert datetime.strptime(json_resp['data']['created_at'], '%Y-%m-%d %H:%M:%S.%f').date() == date.today()
|
||||
assert datetime.strptime(json_resp['data']['created_at'], '%Y-%m-%d %H:%M:%S.%f').date() == \
|
||||
datetime.utcnow().date()
|
||||
|
||||
|
||||
def test_previous_template_history_version(notify_api, sample_template):
|
||||
|
||||
Reference in New Issue
Block a user