mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Log detailed sms delivery status for mmg from process_sms_client_response task.
Also log detailed delivery status for firetext in the same place in addition to it being logged from notifications_dao. Logging detailed delivery statuses will help us see why messages fail to deliver. In the future we could persist detailed delivery status in the database.
This commit is contained in:
@@ -203,6 +203,7 @@ def test_mmg_callback_should_return_200_and_call_task_with_valid_data(client, mo
|
||||
"CID": "notification_id",
|
||||
"MSISDN": "447777349060",
|
||||
"status": "3",
|
||||
"substatus": "5",
|
||||
"deliverytime": "2016-04-05 16:01:07"})
|
||||
|
||||
response = mmg_post(client, data)
|
||||
@@ -212,7 +213,7 @@ def test_mmg_callback_should_return_200_and_call_task_with_valid_data(client, mo
|
||||
assert json_data['result'] == 'success'
|
||||
|
||||
mock_celery.assert_called_once_with(
|
||||
['3', 'notification_id', 'MMG'],
|
||||
['3', 'notification_id', 'MMG', '5'],
|
||||
queue='sms-callbacks',
|
||||
)
|
||||
|
||||
|
||||
@@ -35,25 +35,31 @@ def test_process_sms_response_raises_client_exception_for_unknown_status(
|
||||
assert sample_notification.status == NOTIFICATION_TECHNICAL_FAILURE
|
||||
|
||||
|
||||
@pytest.mark.parametrize('status, sms_provider, expected_notification_status', [
|
||||
('0', 'Firetext', 'delivered'),
|
||||
('1', 'Firetext', 'permanent-failure'),
|
||||
('2', 'Firetext', 'pending'),
|
||||
('2', 'MMG', 'permanent-failure'),
|
||||
('3', 'MMG', 'delivered'),
|
||||
('4', 'MMG', 'temporary-failure'),
|
||||
('5', 'MMG', 'permanent-failure'),
|
||||
@pytest.mark.parametrize('status, substatus, sms_provider, expected_notification_status, reason', [
|
||||
('0', None, 'Firetext', 'delivered', None),
|
||||
('1', '101', 'Firetext', 'permanent-failure', 'Unknown Subscriber'),
|
||||
('2', '102', 'Firetext', 'pending', 'Absent Subscriber'),
|
||||
('2', '1', 'MMG', 'permanent-failure', "Number does not exist"),
|
||||
('3', '2', 'MMG', 'delivered', "Delivered to operator"),
|
||||
('4', '27', 'MMG', 'temporary-failure', "Absent Subscriber"),
|
||||
('5', '13', 'MMG', 'permanent-failure', "Sender id blacklisted"),
|
||||
])
|
||||
def test_process_sms_client_response_updates_notification_status(
|
||||
sample_notification,
|
||||
mocker,
|
||||
status,
|
||||
substatus,
|
||||
sms_provider,
|
||||
expected_notification_status,
|
||||
reason
|
||||
):
|
||||
mock_logger = mocker.patch('app.celery.tasks.current_app.logger.info')
|
||||
sample_notification.status = 'sending'
|
||||
process_sms_client_response(status, str(sample_notification.id), sms_provider)
|
||||
|
||||
process_sms_client_response(status, str(sample_notification.id), sms_provider, substatus)
|
||||
|
||||
message = f"{sms_provider} callback returned status of {expected_notification_status}: {reason} for reference: {sample_notification.id}" # noqa
|
||||
mock_logger.assert_any_call(message)
|
||||
assert sample_notification.status == expected_notification_status
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user