mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
Add tests for notification.template returning the right version
Adds test for: * checking the template version foreign key constraint * checking that template changes don't affect existing notifications * notification statistics aren't affected by different template versions * notification stats always return the current template name
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from freezegun import freeze_time
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from app import encryption
|
||||
from app.models import (
|
||||
@@ -239,6 +240,24 @@ def test_letter_notification_serializes_with_subject(client, sample_letter_templ
|
||||
assert res['subject'] == 'Template subject'
|
||||
|
||||
|
||||
def test_notification_references_template_history(client, sample_template):
|
||||
noti = create_notification(sample_template)
|
||||
sample_template.version = 3
|
||||
sample_template.content = 'New template content'
|
||||
|
||||
res = noti.serialize()
|
||||
assert res['template']['version'] == 1
|
||||
|
||||
assert res['body'] == noti.template.content
|
||||
assert noti.template.content != sample_template.content
|
||||
|
||||
|
||||
def test_notification_requires_a_valid_template_version(client, sample_template):
|
||||
sample_template.version = 2
|
||||
with pytest.raises(IntegrityError):
|
||||
create_notification(sample_template)
|
||||
|
||||
|
||||
def test_inbound_number_serializes_with_service(client, notify_db_session):
|
||||
service = create_service()
|
||||
inbound_number = create_inbound_number(number='1', service_id=service.id)
|
||||
|
||||
Reference in New Issue
Block a user