Files
notifications-api/tests/app/clients/test_aws_ses.py
Rebecca Law 281a93b32d Update ses callback to interpret hard and soft bounces.
If the notification has a status == sending then update the status otherwise do not update the status.
In other words do not change the status more than once.
2016-05-17 15:38:49 +01:00

42 lines
1.6 KiB
Python

import pytest
from app.clients.email.aws_ses import get_aws_responses
def test_should_return_correct_details_for_delivery():
response_dict = get_aws_responses('Delivery')
assert response_dict['message'] == 'Delivered'
assert response_dict['notification_status'] == 'delivered'
assert response_dict['notification_statistics_status'] == 'delivered'
assert response_dict['success']
def test_should_return_correct_details_for_hard_bounced():
response_dict = get_aws_responses('Permanent')
assert response_dict['message'] == 'Hard bounced'
assert response_dict['notification_status'] == 'permanent-failure'
assert response_dict['notification_statistics_status'] == 'failure'
assert not response_dict['success']
def test_should_return_correct_details_for_soft_bounced():
response_dict = get_aws_responses('Temporary')
assert response_dict['message'] == 'Soft bounced'
assert response_dict['notification_status'] == 'temporary-failure'
assert response_dict['notification_statistics_status'] == 'failure'
assert not response_dict['success']
def test_should_return_correct_details_for_complaint():
response_dict = get_aws_responses('Complaint')
assert response_dict['message'] == 'Complaint'
assert response_dict['notification_status'] == 'delivered'
assert response_dict['notification_statistics_status'] == 'delivered'
assert response_dict['success']
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)