Ensure notifications have billable units and provider if sending fails

If we try to send an SMS to the provider and the provider throws an exception
(because they return a 503 status code) the notification should retry. But if
we get the callback from the provider before the notification has been retried, the
notification will have no billable units or provider set.

To avoid this, we now set billable_units and provider even if there has been
an exception from our provider.
This commit is contained in:
Katie Smith
2019-05-08 10:54:01 +01:00
parent a4ae5a0a90
commit c809bf2207
3 changed files with 28 additions and 5 deletions

View File

@@ -117,6 +117,7 @@ def test_send_sms_should_switch_providers_on_provider_failure(sample_notificatio
provider_to_use.return_value.send_sms.side_effect = Exception('Error')
switch_provider_mock = mocker.patch('app.delivery.send_to_providers.dao_toggle_sms_provider')
mocker.patch('app.celery.provider_tasks.deliver_sms.retry')
mocker.patch('app.delivery.send_to_providers.update_notification_provider')
deliver_sms(sample_notification.id)