mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
don't retry task if InvalidEmailError
just record it as a technical error - retrying wont fix a bad email
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
from celery.exceptions import MaxRetriesExceededError
|
||||
from notifications_utils.recipients import InvalidEmailError
|
||||
|
||||
import app
|
||||
from app.celery import provider_tasks
|
||||
from app.celery.provider_tasks import send_sms_to_provider, send_email_to_provider, deliver_sms, deliver_email
|
||||
from app.clients.email import EmailClientException
|
||||
from app.models import Notification
|
||||
|
||||
from tests.app.conftest import sample_notification
|
||||
import app
|
||||
|
||||
|
||||
def test_should_have_decorated_tasks_functions():
|
||||
@@ -229,3 +232,12 @@ def test_should_go_into_technical_error_if_exceeds_retries_on_deliver_email_task
|
||||
|
||||
db_notification = Notification.query.filter_by(id=notification.id).one()
|
||||
assert db_notification.status == 'technical-failure'
|
||||
|
||||
def test_should_technical_error_and_not_retry_if_invalid_email(sample_notification, mocker):
|
||||
mocker.patch('app.delivery.send_to_providers.send_email_to_provider', side_effect=InvalidEmailError('bad email'))
|
||||
mocker.patch('app.celery.provider_tasks.deliver_email.retry')
|
||||
|
||||
deliver_email(sample_notification.id)
|
||||
|
||||
assert provider_tasks.deliver_email.retry.called is False
|
||||
assert sample_notification.status == 'technical-failure'
|
||||
|
||||
Reference in New Issue
Block a user