Change NotificationHistory.updated_at on update

Sets the updated_at to current time when the NotificationHistory
is modified (which happens occasionally for example to set status
to returned letter).
This commit is contained in:
Alexey Bezhan
2018-09-13 14:09:09 +01:00
parent 5b25b682d4
commit c9ca720959
2 changed files with 10 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ from app.dao import jobs_dao, services_dao
from app.models import (
Job,
Notification,
NotificationHistory,
EMAIL_TYPE,
KEY_TYPE_NORMAL,
KEY_TYPE_TEAM,
@@ -1560,6 +1561,11 @@ def test_process_returned_letters_list(mocker, sample_letter_template):
process_returned_letters_list(['ref1', 'ref2', 'unknown-ref'])
assert [
n.status for n in Notification.query.all()
] == ['returned-letter', 'returned-letter']
notifications = Notification.query.all()
history = NotificationHistory.query.all()
assert [n.status for n in notifications] == ['returned-letter', 'returned-letter']
assert all(n.updated_at for n in notifications)
assert [n.status for n in history] == ['returned-letter', 'returned-letter']
assert all(n.updated_at for n in history)