We are not handling the case of an unknown status code sent by the SMS provider. This PR attempts to fix that.

- If the SMS client sends a status code that we do not recognize raise a ClientException and set the notification status to technical-failure
- Simplified the code in process_client_response, using a simple map.
This commit is contained in:
Rebecca Law
2018-02-07 17:49:15 +00:00
parent a5343fb837
commit b2dfa59b1b
7 changed files with 60 additions and 120 deletions

View File

@@ -9,27 +9,15 @@ from app.clients.sms.firetext import get_firetext_responses, SmsClientResponseEx
def test_should_return_correct_details_for_delivery():
response_dict = get_firetext_responses('0')
assert response_dict['message'] == 'Delivered'
assert response_dict['notification_status'] == 'delivered'
assert response_dict['notification_statistics_status'] == 'delivered'
assert response_dict['success']
get_firetext_responses('0') == 'delivered'
def test_should_return_correct_details_for_bounced():
response_dict = get_firetext_responses('1')
assert response_dict['message'] == 'Declined'
assert response_dict['notification_status'] == 'permanent-failure'
assert response_dict['notification_statistics_status'] == 'failure'
assert not response_dict['success']
get_firetext_responses('1') == 'permanent-failure'
def test_should_return_correct_details_for_complaint():
response_dict = get_firetext_responses('2')
assert response_dict['message'] == 'Undelivered (Pending with Network)'
assert response_dict['notification_status'] == 'pending'
assert response_dict['notification_statistics_status'] is None
assert response_dict['success']
get_firetext_responses('2') == 'pending'
def test_should_be_none_if_unrecognised_status_code():