From 23dfa2d53509e659475eed04630337564acce349 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Wed, 22 Jun 2016 14:42:55 +0100 Subject: [PATCH] Added created as a status type that can be updated. --- app/dao/notifications_dao.py | 3 ++- tests/app/dao/test_notification_dao.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index b0cef9dc4..cc3cee647 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -248,7 +248,8 @@ def _update_notification_status(notification, status, notification_statistics_st def update_notification_status_by_id(notification_id, status, notification_statistics_status=None): notification = Notification.query.filter( Notification.id == notification_id, - or_(Notification.status == 'sending', + or_(Notification.status == 'created', + Notification.status == 'sending', Notification.status == 'pending')).first() if not notification: diff --git a/tests/app/dao/test_notification_dao.py b/tests/app/dao/test_notification_dao.py index 4e6a2e9f3..45e78fc33 100644 --- a/tests/app/dao/test_notification_dao.py +++ b/tests/app/dao/test_notification_dao.py @@ -75,6 +75,12 @@ def test_should_not_update_status_by_id_if_not_sending_and_does_not_update_job(n assert job == Job.query.get(notification.job_id) +def test_should_update_status_if_created(notify_db, notify_db_session): + notification = sample_notification(notify_db, notify_db_session, status='created') + assert Notification.query.get(notification.id).status == 'created' + assert update_notification_status_by_id(notification.id, 'failed', 'failure') + + def test_should_by_able_to_update_status_by_id_from_pending_to_delivered(sample_template, sample_job): data = _notification_json(sample_template, job_id=sample_job.id) notification = Notification(**data)