mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Added base object for response statuses, and tests around it's behaviour
This commit is contained in:
0
tests/app/clients/__init__.py
Normal file
0
tests/app/clients/__init__.py
Normal file
32
tests/app/clients/test_aws_ses.py
Normal file
32
tests/app/clients/test_aws_ses.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import pytest
|
||||
|
||||
from app.clients.email import aws_ses
|
||||
|
||||
aws_responses = aws_ses.AwsSesResponses()
|
||||
|
||||
|
||||
def test_should_return_correct_details_for_delivery():
|
||||
assert aws_responses.response_code_to_message('Delivery') == 'Delivered'
|
||||
assert aws_responses.response_code_to_notification_status('Delivery') == 'delivered'
|
||||
assert aws_responses.response_code_to_notification_statistics_status('Delivery') == 'delivered'
|
||||
assert aws_responses.response_code_to_notification_success('Delivery')
|
||||
|
||||
|
||||
def test_should_return_correct_details_for_bounced():
|
||||
assert aws_responses.response_code_to_message('Bounce') == 'Bounced'
|
||||
assert aws_responses.response_code_to_notification_status('Bounce') == 'bounce'
|
||||
assert aws_responses.response_code_to_notification_statistics_status('Bounce') == 'failed'
|
||||
assert not aws_responses.response_code_to_notification_success('Bounce')
|
||||
|
||||
|
||||
def test_should_return_correct_details_for_complaint():
|
||||
assert aws_responses.response_code_to_message('Complaint') == 'Complaint'
|
||||
assert aws_responses.response_code_to_notification_status('Complaint') == 'complaint'
|
||||
assert aws_responses.response_code_to_notification_statistics_status('Complaint') == 'failed'
|
||||
assert not aws_responses.response_code_to_notification_success('Complaint')
|
||||
|
||||
|
||||
def test_should_be_none_if_unrecognised_status_code():
|
||||
with pytest.raises(KeyError) as e:
|
||||
aws_responses.response_code_to_object('99')
|
||||
assert '99' in str(e.value)
|
||||
32
tests/app/clients/test_firetext.py
Normal file
32
tests/app/clients/test_firetext.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import pytest
|
||||
|
||||
from app.clients.sms import firetext
|
||||
|
||||
responses = firetext.FiretextResponses()
|
||||
|
||||
|
||||
def test_should_return_correct_details_for_delivery():
|
||||
assert responses.response_code_to_message('0') == 'Delivered'
|
||||
assert responses.response_code_to_notification_status('0') == 'delivered'
|
||||
assert responses.response_code_to_notification_statistics_status('0') == 'delivered'
|
||||
assert responses.response_code_to_notification_success('0')
|
||||
|
||||
|
||||
def test_should_return_correct_details_for_bounced():
|
||||
assert responses.response_code_to_message('1') == 'Declined'
|
||||
assert responses.response_code_to_notification_status('1') == 'failed'
|
||||
assert responses.response_code_to_notification_statistics_status('1') == 'failed'
|
||||
assert not responses.response_code_to_notification_success('1')
|
||||
|
||||
|
||||
def test_should_return_correct_details_for_complaint():
|
||||
assert responses.response_code_to_message('2') == 'Undelivered (Pending with Network)'
|
||||
assert responses.response_code_to_notification_status('2') == 'sent'
|
||||
assert not responses.response_code_to_notification_statistics_status('2')
|
||||
assert not responses.response_code_to_notification_success('2')
|
||||
|
||||
|
||||
def test_should_be_none_if_unrecognised_status_code():
|
||||
with pytest.raises(KeyError) as e:
|
||||
responses.response_code_to_object('99')
|
||||
assert '99' in str(e.value)
|
||||
Reference in New Issue
Block a user