mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
trigger nightly delete tasks from the create notification status task
the nightly tasks need to run after the create nightly notification status task - so that test notifications are still there to record stats for, and to stop the risk of deleting notificaitons part-way through recording stats for them.
This commit is contained in:
@@ -429,7 +429,13 @@ def test_create_nightly_billing_update_when_record_exists(
|
||||
assert records[0].updated_at
|
||||
|
||||
|
||||
def test_create_nightly_notification_status(notify_db_session):
|
||||
def test_create_nightly_notification_status(notify_db_session, mocker):
|
||||
mocks = [
|
||||
mocker.patch('app.celery.reporting_tasks.delete_email_notifications_older_than_retention'),
|
||||
mocker.patch('app.celery.reporting_tasks.delete_sms_notifications_older_than_retention'),
|
||||
mocker.patch('app.celery.reporting_tasks.delete_letter_notifications_older_than_retention'),
|
||||
]
|
||||
|
||||
first_service = create_service(service_name='First Service')
|
||||
first_template = create_template(service=first_service)
|
||||
second_service = create_service(service_name='second Service')
|
||||
@@ -471,10 +477,17 @@ def test_create_nightly_notification_status(notify_db_session):
|
||||
assert str(new_data[3].bst_date) == datetime.strftime(datetime.utcnow() - timedelta(days=2), "%Y-%m-%d")
|
||||
assert str(new_data[6].bst_date) == datetime.strftime(datetime.utcnow() - timedelta(days=1), "%Y-%m-%d")
|
||||
|
||||
for mock in mocks:
|
||||
mock.apply_async.assert_called_once_with(queue='periodic-tasks')
|
||||
|
||||
|
||||
# the job runs at 12:30am London time. 04/01 is in BST.
|
||||
@freeze_time('2019-04-01T23:30')
|
||||
def test_create_nightly_notification_status_respects_bst(sample_template):
|
||||
def test_create_nightly_notification_status_respects_bst(sample_template, mocker):
|
||||
mocker.patch('app.celery.reporting_tasks.delete_email_notifications_older_than_retention')
|
||||
mocker.patch('app.celery.reporting_tasks.delete_sms_notifications_older_than_retention')
|
||||
mocker.patch('app.celery.reporting_tasks.delete_letter_notifications_older_than_retention')
|
||||
|
||||
create_notification(sample_template, status='delivered', created_at=datetime(2019, 4, 1, 23, 0)) # too new
|
||||
|
||||
create_notification(sample_template, status='created', created_at=datetime(2019, 4, 1, 22, 59))
|
||||
|
||||
Reference in New Issue
Block a user