mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 09:21:39 -05:00
Merge pull request #462 from alphagov/allow-created-notifications-to-be-updated
Added created as a status type that can be updated.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user