mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 14:08:47 -04:00
fix tests
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import json
|
import json
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from unittest.mock import ANY, MagicMock, Mock
|
from unittest.mock import ANY, Mock
|
||||||
|
|
||||||
import botocore
|
import botocore
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from app.clients.email import EmailClientNonRetryableException
|
from app.clients.email import EmailClientNonRetryableException
|
||||||
from app.clients.email.aws_ses import (
|
from app.clients.email.aws_ses import (
|
||||||
|
AwsSesClient,
|
||||||
AwsSesClientException,
|
AwsSesClientException,
|
||||||
AwsSesClientThrottlingSendRateException,
|
AwsSesClientThrottlingSendRateException,
|
||||||
get_aws_responses,
|
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.clients.email.aws_ses_stub import AwsSesStubClient
|
||||||
from app.enums import NotificationStatus, StatisticsType
|
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():
|
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(
|
def test_send_email_handles_reply_to_address(
|
||||||
notify_api, mocker, reply_to_address, expected_value
|
notify_api, mocker, reply_to_address, expected_value
|
||||||
):
|
):
|
||||||
|
aws_ses_client = AwsSesClient()
|
||||||
|
|
||||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||||
|
|
||||||
with notify_api.app_context():
|
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):
|
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)
|
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||||
|
|
||||||
with notify_api.app_context():
|
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(
|
def test_send_email_raises_invalid_parameter_value_error_as_EmailClientNonRetryableException(
|
||||||
mocker,
|
mocker,
|
||||||
):
|
):
|
||||||
|
aws_ses_client = AwsSesClient()
|
||||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||||
error_response = {
|
error_response = {
|
||||||
"Error": {
|
"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(
|
def test_send_email_raises_send_rate_throttling_as_AwsSesClientThrottlingSendRateException(
|
||||||
mocker,
|
mocker,
|
||||||
):
|
):
|
||||||
|
aws_ses_client = AwsSesClient()
|
||||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||||
error_response = {
|
error_response = {
|
||||||
"Error": {
|
"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(
|
def test_send_email_does_not_raise_AwsSesClientThrottlingSendRateException_if_non_send_rate_throttling(
|
||||||
mocker,
|
mocker,
|
||||||
):
|
):
|
||||||
|
aws_ses_client = AwsSesClient()
|
||||||
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||||
error_response = {
|
error_response = {
|
||||||
"Error": {
|
"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):
|
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)
|
boto_mock = mocker.patch.object(aws_ses_client, "_client", create=True)
|
||||||
error_response = {
|
error_response = {
|
||||||
"Error": {
|
"Error": {
|
||||||
|
|||||||
Reference in New Issue
Block a user