Only send to the provider if the notification has a created status.

If the notification ends up in the retry queue and the delivery app is restarted the notification will get sent twice.
This is because when the app is restarted another message will be in the retry queue as message available which is a
duplicate of the one in the queue that is a  message in flight.

This should complete https://www.pivotaltracker.com/story/show/121844427
This commit is contained in:
Rebecca Law
2016-06-27 14:47:20 +01:00
parent 8f19ad19f8
commit 8a0211b3eb
6 changed files with 69 additions and 58 deletions

View File

@@ -116,7 +116,8 @@ def test_send_sms_should_use_template_version_from_notification_not_latest(
sample_template,
mocker):
db_notification = sample_notification(notify_db, notify_db_session,
template=sample_template, to_field='+447234123123')
template=sample_template, to_field='+447234123123',
status='created')
mocker.patch('app.mmg_client.send_sms')
mocker.patch('app.mmg_client.get_name', return_value="mmg")
@@ -146,6 +147,7 @@ def test_send_sms_should_use_template_version_from_notification_not_latest(
assert persisted_notification.template_version == version_on_notification
assert persisted_notification.template_version != sample_template.version
assert persisted_notification.content_char_count == len("Sample service: This is a template")
assert persisted_notification.status == 'sending'
assert not persisted_notification.personalisation