remove reply_to_addresses from task kwargs

also added a test for aws_ses.send_email to prove it handles reply_to_address correctly
This commit is contained in:
Leo Hemsted
2016-07-04 17:29:41 +01:00
parent e5b417305f
commit 242be97bfa
5 changed files with 29 additions and 53 deletions

View File

@@ -1,5 +1,7 @@
import pytest
from unittest.mock import Mock, ANY
from app import aws_ses_client
from app.clients.email.aws_ses import get_aws_responses
@@ -39,3 +41,29 @@ def test_should_be_none_if_unrecognised_status_code():
with pytest.raises(KeyError) as e:
get_aws_responses('99')
assert '99' in str(e.value)
@pytest.mark.parametrize(
'reply_to_address, expected_value',
[(None, []), ('foo@bar.com', ['foo@bar.com'])],
ids=['empty', 'single_email']
)
def test_send_email_handles_reply_to_address(notify_api, mocker, reply_to_address, expected_value):
boto_mock = mocker.patch.object(aws_ses_client, '_client', create=True)
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
with notify_api.app_context():
aws_ses_client.send_email(
Mock(),
Mock(),
Mock(),
Mock(),
reply_to_address=reply_to_address
)
boto_mock.send_email.assert_called_once_with(
Source=ANY,
Destination=ANY,
Message=ANY,
ReplyToAddresses=expected_value
)