fix tests

This commit is contained in:
Kenneth Kehl
2024-03-06 10:55:03 -08:00
parent 492daee970
commit e2b2cdcfbc

View File

@@ -1,3 +1,5 @@
import json
import pytest
from botocore.exceptions import ClientError
from celery.exceptions import MaxRetriesExceededError
@@ -117,7 +119,7 @@ def test_should_call_send_email_to_provider_from_deliver_email_task(
sample_notification, mocker
):
mocker.patch("app.delivery.send_to_providers.send_email_to_provider")
mocker.patch("app.redis_store.get", return_value=json.dumps({}))
deliver_email(sample_notification.id)
app.delivery.send_to_providers.send_email_to_provider.assert_called_with(
sample_notification
@@ -174,6 +176,7 @@ def test_should_technical_error_and_not_retry_if_EmailClientNonRetryableExceptio
"app.delivery.send_to_providers.send_email_to_provider",
side_effect=EmailClientNonRetryableException("bad email"),
)
mocker.patch("app.redis_store.get", return_value=json.dumps({}))
mocker.patch("app.celery.provider_tasks.deliver_email.retry")
deliver_email(sample_notification.id)
@@ -197,6 +200,7 @@ def test_should_retry_and_log_exception_for_deliver_email_task(
"app.delivery.send_to_providers.send_email_to_provider",
side_effect=AwsSesClientException(str(ex)),
)
mocker.patch("app.celery.provider_tasks.deliver_email.retry")
mock_logger_exception = mocker.patch(
"app.celery.tasks.current_app.logger.exception"
@@ -220,6 +224,7 @@ def test_if_ses_send_rate_throttle_then_should_retry_and_log_warning(
}
}
ex = ClientError(error_response=error_response, operation_name="opname")
mocker.patch("app.redis_store.get", return_value=json.dumps({}))
mocker.patch(
"app.delivery.send_to_providers.send_email_to_provider",
side_effect=AwsSesClientThrottlingSendRateException(str(ex)),