mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Add new task to alert about created email / sms
This will log an error when email or SMS notifications have been stuck in 'created' for too long - normally they should be 'sending' in seconds, noting that we have a goal of < 10s wait time for most notifications being processed our platform. In the next commits we'll decouple similar functionality from the existing 'timeout-sending-notifications' task.
This commit is contained in:
@@ -19,6 +19,7 @@ from app.celery.scheduled_tasks import (
|
||||
check_job_status,
|
||||
delete_invitations,
|
||||
delete_verify_codes,
|
||||
raise_alert_if_email_sms_still_in_created,
|
||||
remove_yesterdays_planned_tests_on_govuk_alerts,
|
||||
replay_created_notifications,
|
||||
run_scheduled_jobs,
|
||||
@@ -108,6 +109,24 @@ def test_should_update_all_scheduled_jobs_and_put_on_queue(sample_template, mock
|
||||
])
|
||||
|
||||
|
||||
def test_raise_alert_if_email_sms_still_in_created(notify_api, mocker):
|
||||
mock_check = mocker.patch('app.celery.scheduled_tasks.dao_check_notifications_still_in_created')
|
||||
mock_logger = mocker.patch('app.celery.scheduled_tasks.current_app.logger')
|
||||
|
||||
mock_check.return_value = 0
|
||||
raise_alert_if_email_sms_still_in_created()
|
||||
mock_logger.info.assert_called_once_with("0 notifications are still in 'created'.")
|
||||
|
||||
assert mock_check.called_once_with(
|
||||
notify_api.config['CREATED_NOTIFICATIONS_ALERT_AGE']
|
||||
)
|
||||
|
||||
# try again with something to alert about
|
||||
mock_check.return_value = 1
|
||||
raise_alert_if_email_sms_still_in_created()
|
||||
mock_logger.error.assert_called_once_with("1 notifications are still in 'created'.")
|
||||
|
||||
|
||||
@freeze_time('2017-05-01 14:00:00')
|
||||
def test_switch_current_sms_provider_on_slow_delivery_switches_when_one_provider_is_slow(
|
||||
mocker,
|
||||
|
||||
Reference in New Issue
Block a user