From 8e19a0742f11fc2400605b3e6d9a0bc783196f6a Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 20 Sep 2018 12:26:58 +0100 Subject: [PATCH] remove default postage from noti history also add test for notification_history properly setting --- app/models.py | 2 +- .../app/v2/notifications/test_post_letter_notifications.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models.py b/app/models.py index 76cce1fb8..f5f064615 100644 --- a/app/models.py +++ b/app/models.py @@ -1436,7 +1436,7 @@ class NotificationHistory(db.Model, HistoryModel): created_by = db.relationship('User') created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), nullable=True) - postage = db.Column(db.String, nullable=True, default='second') + postage = db.Column(db.String, nullable=True) CheckConstraint("notification_type != 'letter' or postage in ('first', 'second')") __table_args__ = ( diff --git a/tests/app/v2/notifications/test_post_letter_notifications.py b/tests/app/v2/notifications/test_post_letter_notifications.py index cbf9ca471..a984d5e78 100644 --- a/tests/app/v2/notifications/test_post_letter_notifications.py +++ b/tests/app/v2/notifications/test_post_letter_notifications.py @@ -9,6 +9,7 @@ from app.config import TaskNames, QueueNames from app.models import ( Job, Notification, + NotificationHistory, EMAIL_TYPE, KEY_TYPE_NORMAL, KEY_TYPE_TEAM, @@ -483,12 +484,15 @@ def test_post_precompiled_letter_notification_returns_201(client, notify_user, m s3mock.assert_called_once_with(ANY, b'letter-content', precompiled=True) - notification = Notification.query.first() + notification = Notification.query.one() assert notification.billable_units == 3 assert notification.status == NOTIFICATION_PENDING_VIRUS_CHECK assert notification.postage == postage + notification_history = NotificationHistory.query.one() + assert notification_history.postage == postage + resp_json = json.loads(response.get_data(as_text=True)) assert resp_json == {'id': str(notification.id), 'reference': 'letter-reference'}