mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-10 23:32:27 -05:00
fix tests
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import json
|
||||
from unittest import mock
|
||||
from unittest.mock import ANY, MagicMock, Mock
|
||||
from unittest.mock import ANY, Mock
|
||||
|
||||
import botocore
|
||||
import pytest
|
||||
|
||||
from app.clients.email import EmailClientNonRetryableException
|
||||
from app.clients.email.aws_ses import (
|
||||
AwsSesClient,
|
||||
AwsSesClientException,
|
||||
AwsSesClientThrottlingSendRateException,
|
||||
get_aws_responses,
|
||||
@@ -14,8 +15,6 @@ from app.clients.email.aws_ses import (
|
||||
from app.clients.email.aws_ses_stub import AwsSesStubClient
|
||||
from app.enums import NotificationStatus, StatisticsType
|
||||
|
||||
# comes from app/__init__.py but we mock it for the tests
|
||||
aws_ses_client = MagicMock()
|
||||
|
||||
|
||||
def test_should_return_correct_details_for_delivery():
|
||||
@@ -68,6 +67,8 @@ def test_should_be_none_if_unrecognised_status_code():
|
||||
def test_send_email_handles_reply_to_address(
|
||||
notify_api, mocker, reply_to_address, expected_value
|
||||
):
|
||||
aws_ses_client = AwsSesClient()
|
||||
|
||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||
|
||||
with notify_api.app_context():
|
||||
@@ -85,6 +86,7 @@ def test_send_email_handles_reply_to_address(
|
||||
|
||||
|
||||
def test_send_email_handles_punycode_to_address(notify_api, mocker):
|
||||
aws_ses_client = AwsSesClient()
|
||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||
|
||||
with notify_api.app_context():
|
||||
@@ -107,6 +109,7 @@ def test_send_email_handles_punycode_to_address(notify_api, mocker):
|
||||
def test_send_email_raises_invalid_parameter_value_error_as_EmailClientNonRetryableException(
|
||||
mocker,
|
||||
):
|
||||
aws_ses_client = AwsSesClient()
|
||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||
error_response = {
|
||||
"Error": {
|
||||
@@ -133,6 +136,7 @@ def test_send_email_raises_invalid_parameter_value_error_as_EmailClientNonRetrya
|
||||
def test_send_email_raises_send_rate_throttling_as_AwsSesClientThrottlingSendRateException(
|
||||
mocker,
|
||||
):
|
||||
aws_ses_client = AwsSesClient()
|
||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||
error_response = {
|
||||
"Error": {
|
||||
@@ -154,6 +158,7 @@ def test_send_email_raises_send_rate_throttling_as_AwsSesClientThrottlingSendRat
|
||||
def test_send_email_does_not_raise_AwsSesClientThrottlingSendRateException_if_non_send_rate_throttling(
|
||||
mocker,
|
||||
):
|
||||
aws_ses_client = AwsSesClient()
|
||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||
error_response = {
|
||||
"Error": {
|
||||
@@ -173,6 +178,7 @@ def test_send_email_does_not_raise_AwsSesClientThrottlingSendRateException_if_no
|
||||
|
||||
|
||||
def test_send_email_raises_other_errs_as_AwsSesClientException(mocker):
|
||||
aws_ses_client = AwsSesClient()
|
||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||
error_response = {
|
||||
"Error": {
|
||||
|
||||
Reference in New Issue
Block a user