mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
Avoid assigning notification.template when creating test objects
`Notification.template` changed from being a Template relationship to TemplateHistory. When a relationship attribute is being assigned, SQLAlchemy checks that the assigned value type matches the relationship type. Since most tests at the moment create a notification using a Template instance this check fails. Rewriting the tests to use TemplateHistory objects would require changes to the majority of tests. Instead, when creating a notification objects we assign the foreign key attributes directly. This skips the SQLAlchemy type check, but we still get the constraint check on the foreign keys, so a matching TemplateHistory object needs to exist in the database.
This commit is contained in:
@@ -202,8 +202,8 @@ def test_notification_subject_fills_in_placeholders_for_email(sample_email_templ
|
||||
|
||||
|
||||
def test_notification_subject_fills_in_placeholders_for_letter(sample_letter_template):
|
||||
sample_letter_template.subject = '((name))'
|
||||
noti = create_notification(sample_letter_template, personalisation={'name': 'hello'})
|
||||
noti.template.subject = '((name))'
|
||||
assert noti.subject == 'hello'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user