mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 16:23:44 -04:00
Refactor method for deciding the failure type
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user