Reinstating the 2 task model for API submitted notifications.

This is being done for the PaaS migration to allow us to keep traffic coming in whilst we migrate the database.

uses the same tasks as the CSV uploaded notifications. Simple changes to not persist the notification, and call into a different task.
This commit is contained in:
Martyn Inglis
2017-03-23 14:41:00 +00:00
parent 5fcc80c7be
commit 1c154c4113
8 changed files with 348 additions and 106 deletions

View File

@@ -77,6 +77,34 @@ def test_persist_notification_creates_and_save_to_db(sample_template, sample_api
mocked_redis.assert_called_once_with(str(sample_template.service_id) + "-2016-01-01-count")
@freeze_time("2016-01-01 11:09:00.061258")
def test_persist_notification_does_not_create_and_save_to_db_if_persist_is_false(
sample_template, sample_api_key, sample_job, mocker
):
mocked_redis = mocker.patch('app.notifications.process_notifications.redis_store.get')
assert Notification.query.count() == 0
assert NotificationHistory.query.count() == 0
persist_notification(
sample_template.id,
sample_template.version,
'+447111111111',
sample_template.service,
{},
'sms',
sample_api_key.id,
sample_api_key.key_type,
job_id=sample_job.id,
job_row_number=100,
reference="ref",
persist=False)
assert Notification.query.count() == 0
assert NotificationHistory.query.count() == 0
mocked_redis.assert_called_once_with(str(sample_template.service_id) + "-2016-01-01-count")
def test_persist_notification_throws_exception_when_missing_template(sample_api_key):
assert Notification.query.count() == 0
assert NotificationHistory.query.count() == 0