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:
Alexey Bezhan
2017-11-10 11:33:42 +00:00
parent db1c647873
commit 0825177f2d
3 changed files with 57 additions and 10 deletions

View File

@@ -1451,6 +1451,24 @@ def test_get_notification_for_service_includes_created_by(admin_request, sample_
}
def test_get_notification_for_service_returns_old_template_version(admin_request, sample_template):
sample_notification = create_notification(sample_template)
sample_notification.reference = 'modified-inplace'
sample_template.version = 2
sample_template.content = 'New template content'
resp = admin_request.get(
'service.get_notification_for_service',
service_id=sample_notification.service_id,
notification_id=sample_notification.id
)
assert resp['reference'] == 'modified-inplace'
assert resp['template']['version'] == 1
assert resp['template']['content'] == sample_notification.template.content
assert resp['template']['content'] != sample_template.content
@pytest.mark.parametrize(
'include_from_test_key, expected_count_of_notifications',
[