mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 00:41:35 -05:00
Delete functions which call the job statistics tasks
The JobStatistics table is going to be deleted. There are currently 3 tasks which use the JobStatistics model via the Statistics DAO, so we need to make sure that these tasks aren't being used before they are deleted in a separate PR. This commit deletes: * The `create_initial_notification_statistic_tasks` function which gets used to call the `record_initial_job_statistics` task. * The `create_outcome_notification_statistic_tasks` function which gets used to call the `record_outcome_job_statistics` task. * And the scheduling of the `timeout-job-statistics` scheduled task.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from datetime import datetime
|
||||
from unittest.mock import call
|
||||
|
||||
from flask import json
|
||||
from freezegun import freeze_time
|
||||
@@ -22,9 +21,6 @@ def test_ses_callback_should_update_notification_status(
|
||||
with freeze_time('2001-01-01T12:00:00'):
|
||||
mocker.patch('app.statsd_client.incr')
|
||||
mocker.patch('app.statsd_client.timing_with_dates')
|
||||
stats_mock = mocker.patch(
|
||||
'app.notifications.notifications_ses_callback.create_outcome_notification_statistic_tasks'
|
||||
)
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
@@ -46,7 +42,6 @@ def test_ses_callback_should_update_notification_status(
|
||||
"callback.ses.elapsed-time", datetime.utcnow(), notification.sent_at
|
||||
)
|
||||
statsd_client.incr.assert_any_call("callback.ses.delivered")
|
||||
stats_mock.assert_called_once_with(notification)
|
||||
send_mock.assert_called_once_with([str(notification.id)], queue="service-callbacks")
|
||||
|
||||
|
||||
@@ -86,13 +81,10 @@ def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
sample_email_template,
|
||||
mocker):
|
||||
|
||||
stats_mock = mocker.patch(
|
||||
'app.notifications.notifications_ses_callback.create_outcome_notification_statistic_tasks'
|
||||
)
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
notification1 = create_sample_notification(
|
||||
create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template=sample_email_template,
|
||||
@@ -100,7 +92,7 @@ def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
sent_at=datetime.utcnow(),
|
||||
status='sending')
|
||||
|
||||
notification2 = create_sample_notification(
|
||||
create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template=sample_email_template,
|
||||
@@ -108,7 +100,7 @@ def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
sent_at=datetime.utcnow(),
|
||||
status='sending')
|
||||
|
||||
notification3 = create_sample_notification(
|
||||
create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template=sample_email_template,
|
||||
@@ -119,12 +111,6 @@ def test_ses_callback_should_update_multiple_notification_status_sent(
|
||||
assert process_ses_response(ses_notification_callback(reference='ref1')) is None
|
||||
assert process_ses_response(ses_notification_callback(reference='ref2')) is None
|
||||
assert process_ses_response(ses_notification_callback(reference='ref3')) is None
|
||||
|
||||
stats_mock.assert_has_calls([
|
||||
call(notification1),
|
||||
call(notification2),
|
||||
call(notification3)
|
||||
])
|
||||
assert send_mock.called
|
||||
|
||||
|
||||
@@ -133,10 +119,6 @@ def test_ses_callback_should_set_status_to_temporary_failure(client,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
|
||||
stats_mock = mocker.patch(
|
||||
'app.notifications.notifications_ses_callback.create_outcome_notification_statistic_tasks'
|
||||
)
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
@@ -153,7 +135,6 @@ def test_ses_callback_should_set_status_to_temporary_failure(client,
|
||||
assert process_ses_response(ses_soft_bounce_callback(reference='ref')) is None
|
||||
assert get_notification_by_id(notification.id).status == 'temporary-failure'
|
||||
assert send_mock.called
|
||||
stats_mock.assert_called_once_with(notification)
|
||||
|
||||
|
||||
def test_ses_callback_should_not_set_status_once_status_is_delivered(client,
|
||||
@@ -161,10 +142,6 @@ def test_ses_callback_should_not_set_status_once_status_is_delivered(client,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
stats_mock = mocker.patch(
|
||||
'app.notifications.notifications_ses_callback.create_outcome_notification_statistic_tasks'
|
||||
)
|
||||
|
||||
notification = create_sample_notification(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
@@ -175,7 +152,6 @@ def test_ses_callback_should_not_set_status_once_status_is_delivered(client,
|
||||
)
|
||||
|
||||
assert get_notification_by_id(notification.id).status == 'delivered'
|
||||
stats_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_ses_callback_should_set_status_to_permanent_failure(client,
|
||||
@@ -183,9 +159,6 @@ def test_ses_callback_should_set_status_to_permanent_failure(client,
|
||||
notify_db_session,
|
||||
sample_email_template,
|
||||
mocker):
|
||||
stats_mock = mocker.patch(
|
||||
'app.notifications.notifications_ses_callback.create_outcome_notification_statistic_tasks'
|
||||
)
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
@@ -203,7 +176,6 @@ def test_ses_callback_should_set_status_to_permanent_failure(client,
|
||||
assert process_ses_response(ses_hard_bounce_callback(reference='ref')) is None
|
||||
assert get_notification_by_id(notification.id).status == 'permanent-failure'
|
||||
assert send_mock.called
|
||||
stats_mock.assert_called_once_with(notification)
|
||||
|
||||
|
||||
def test_remove_emails_from_bounce():
|
||||
|
||||
Reference in New Issue
Block a user