update time handling for more tests

This commit is contained in:
stvnrlly
2022-11-10 16:54:48 -05:00
parent b50cb4712f
commit 3528bd37e1
10 changed files with 43 additions and 43 deletions

View File

@@ -2162,10 +2162,10 @@ def test_get_detailed_services_includes_services_with_no_notifications(notify_db
def test_get_detailed_services_only_includes_todays_notifications(sample_template):
from app.service.rest import get_detailed_services
create_notification(sample_template, created_at=datetime(2015, 10, 9, 23, 59))
create_notification(sample_template, created_at=datetime(2015, 10, 10, 0, 0))
create_notification(sample_template, created_at=datetime(2015, 10, 10, 3, 59))
create_notification(sample_template, created_at=datetime(2015, 10, 10, 4, 0))
create_notification(sample_template, created_at=datetime(2015, 10, 10, 12, 0))
create_notification(sample_template, created_at=datetime(2015, 10, 10, 23, 0))
create_notification(sample_template, created_at=datetime(2015, 10, 11, 3, 0))
with freeze_time('2015-10-10T12:00:00'):
data = get_detailed_services(start_date=datetime.utcnow().date(), end_date=datetime.utcnow().date())

View File

@@ -175,7 +175,7 @@ def _stats(requested, delivered, failed):
]
)
])
@freeze_time('2018-05-31 23:59:59')
@freeze_time('2018-06-01 04:59:59')
def test_create_empty_monthly_notification_status_stats_dict(year, expected_years):
output = create_empty_monthly_notification_status_stats_dict(year)
assert sorted(output.keys()) == expected_years
@@ -183,7 +183,7 @@ def test_create_empty_monthly_notification_status_stats_dict(year, expected_year
assert v == {'sms': {}, 'email': {}, 'letter': {}}
@freeze_time('2018-05-31 23:59:59')
@freeze_time('2018-06-01 04:59:59')
def test_add_monthly_notification_status_stats():
row_data = [
{'month': datetime(2018, 4, 1), 'notification_type': 'sms', 'notification_status': 'sending', 'count': 1},

View File

@@ -1,5 +1,5 @@
import uuid
from datetime import date, datetime
from datetime import date, datetime, timedelta
import pytest
from freezegun import freeze_time
@@ -21,7 +21,7 @@ from tests.app.db import (
)
@freeze_time('2017-11-11 02:00')
@freeze_time('2017-11-11 06:00')
def test_get_template_usage_by_month_returns_correct_data(
admin_request,
sample_template
@@ -53,7 +53,7 @@ def test_get_template_usage_by_month_returns_correct_data(
assert resp_json[1]["count"] == 1
@freeze_time('2017-11-11 02:00')
@freeze_time('2017-11-11 06:00')
def test_get_template_usage_by_month_returns_two_templates(admin_request, sample_template, sample_service):
template_one = create_template(
sample_service,
@@ -213,14 +213,14 @@ def test_get_monthly_notification_stats_returns_stats(admin_request, sample_serv
@freeze_time('2016-06-05 12:00:00')
def test_get_monthly_notification_stats_combines_todays_data_and_historic_stats(admin_request, sample_template):
create_ft_notification_status(datetime(2016, 5, 1), template=sample_template, count=1)
create_ft_notification_status(datetime(2016, 6, 1), template=sample_template, notification_status='created', count=2) # noqa
create_ft_notification_status(datetime(2016, 5, 1, 12), template=sample_template, count=1)
create_ft_notification_status(datetime(2016, 6, 1, 12), template=sample_template, notification_status='created', count=2) # noqa
create_notification(sample_template, created_at=datetime(2016, 6, 5), status='created')
create_notification(sample_template, created_at=datetime(2016, 6, 5), status='delivered')
create_notification(sample_template, created_at=datetime(2016, 6, 5, 12), status='created')
create_notification(sample_template, created_at=datetime(2016, 6, 5, 12), status='delivered')
# this doesn't get returned in the stats because it is old - it should be in ft_notification_status by now
create_notification(sample_template, created_at=datetime(2016, 6, 4), status='sending')
create_notification(sample_template, created_at=datetime(2016, 6, 4, 12), status='sending')
response = admin_request.get(
'service.get_monthly_notification_stats',
@@ -259,10 +259,10 @@ def test_get_monthly_notification_stats_ignores_test_keys(admin_request, sample_
def test_get_monthly_notification_stats_checks_dates(admin_request, sample_service):
t = create_template(sample_service)
create_ft_notification_status(datetime(2016, 3, 31), template=t, notification_status='created')
create_ft_notification_status(datetime(2016, 4, 1), template=t, notification_status='sending')
create_ft_notification_status(datetime(2017, 3, 31), template=t, notification_status='delivered')
create_ft_notification_status(datetime(2017, 4, 11), template=t, notification_status='permanent-failure')
create_ft_notification_status(datetime(2016, 3, 31, 12), template=t, notification_status='created')
create_ft_notification_status(datetime(2016, 4, 1, 12), template=t, notification_status='sending')
create_ft_notification_status(datetime(2017, 3, 31, 12), template=t, notification_status='delivered')
create_ft_notification_status(datetime(2017, 4, 11, 12), template=t, notification_status='permanent-failure')
response = admin_request.get('service.get_monthly_notification_stats', service_id=sample_service.id, year=2016)

View File

@@ -4,13 +4,13 @@ from app.dao.date_util import get_current_financial_year_start_year
# see get_financial_year for conversion of financial years.
@freeze_time("2017-03-31 22:59:59.999999")
@freeze_time("2017-04-01 03:59:59.999999")
def test_get_current_financial_year_start_year_before_march():
current_fy = get_current_financial_year_start_year()
assert current_fy == 2016
@freeze_time("2017-03-31 23:00:00.000000")
@freeze_time("2017-04-01 04:00:00.000000")
def test_get_current_financial_year_start_year_after_april():
current_fy = get_current_financial_year_start_year()
assert current_fy == 2017