When a notification is timed out in the scheduled task that may happen because the notification has not been sent.

Which means the sent_at date for the notification could be empty causing the service callback to fail.

- Allow code to work if notification.sent_at or updated_at is None
- Update calls to send_delivery_status_to_service to send the data encrypted so that the task does not need to use the db.
This commit is contained in:
Rebecca Law
2018-03-16 14:00:49 +00:00
parent 5db110bb3f
commit c9477a7400
8 changed files with 88 additions and 20 deletions

View File

@@ -7,6 +7,7 @@ from app.notifications.process_client_response import (
validate_callback_data,
process_sms_client_response
)
from app.celery.service_callback_tasks import create_encrypted_callback_data
from tests.app.db import create_service_callback_api
@@ -57,13 +58,15 @@ def test_outcome_statistics_called_for_successful_callback(sample_notification,
send_mock = mocker.patch(
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
)
create_service_callback_api(service=sample_notification.service, url="https://original_url.com")
callback_api = create_service_callback_api(service=sample_notification.service, url="https://original_url.com")
reference = str(uuid.uuid4())
success, error = process_sms_client_response(status='3', reference=reference, client_name='MMG')
assert success == "MMG callback succeeded. reference {} updated".format(str(reference))
assert error is None
send_mock.assert_called_once_with([str(sample_notification.id)], queue="service-callbacks")
encrypted_data = create_encrypted_callback_data(sample_notification, callback_api)
send_mock.assert_called_once_with([str(sample_notification.id), encrypted_data],
queue="service-callbacks")
def test_sms_resonse_does_not_call_send_callback_if_no_db_entry(sample_notification, mocker):