Refactor method for deciding the failure type

This commit is contained in:
Rebecca Law
2021-03-10 10:39:17 +00:00
parent a7a504a599
commit 19f7a6ce38
5 changed files with 20 additions and 19 deletions

View File

@@ -9,7 +9,7 @@ from app.clients.sms.firetext import get_firetext_responses, SmsClientResponseEx
@pytest.mark.parametrize('detailed_status_code, result', [
(None, ('delivered', None)), ('000', ('delivered', None))
(None, ('delivered', None)), ('000', ('delivered', 'No error reported'))
])
def test_get_firetext_responses_should_return_correct_details_for_delivery(detailed_status_code, result):
assert get_firetext_responses('0', detailed_status_code) == result

View File

@@ -216,7 +216,7 @@ def test_should_by_able_to_update_status_by_id_from_pending_to_delivered(sample_
def test_should_by_able_to_update_status_by_id_from_pending_to_temporary_failure(sample_template, sample_job):
notification = create_notification(template=sample_template, job=sample_job, status='sending')
notification = create_notification(template=sample_template, job=sample_job, status='sending', sent_by='firetext')
assert update_notification_status_by_id(notification_id=notification.id, status='pending')
assert Notification.query.get(notification.id).status == 'pending'

View File

@@ -67,7 +67,7 @@ def test_process_sms_client_response_updates_notification_status(
('101', 'permanent-failure', 'Unknown Subscriber'),
('102', 'temporary-failure', 'Absent Subscriber'),
(None, 'temporary-failure', None),
('000', 'temporary-failure', None)
('000', 'temporary-failure', 'No error reported')
])
def test_process_sms_client_response_updates_notification_status_when_called_second_time(
sample_notification,
@@ -82,7 +82,7 @@ def test_process_sms_client_response_updates_notification_status_when_called_sec
process_sms_client_response('1', str(sample_notification.id), 'Firetext', detailed_status_code)
if detailed_status_code and detailed_status_code != '000':
if detailed_status_code:
message = f'Updating notification id {sample_notification.id} to status {expected_notification_status}, reason: {reason}' # noqa
mock_logger.assert_called_with(message)