Drop postage constraints

The constaints on notifications and notification_history have already
been dropped in production, but still exist in staging and in dev
environments.

The constraints on templates and templates_history exist in all
environments.
This commit is contained in:
Katie Smith
2020-06-08 11:55:25 +01:00
parent 4b1705aa14
commit bdde035a0c
2 changed files with 69 additions and 35 deletions

View File

@@ -1,7 +1,6 @@
from datetime import datetime
from freezegun import freeze_time
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm.exc import NoResultFound
import pytest
@@ -485,37 +484,3 @@ def test_get_template_versions_is_empty_for_hidden_templates(sample_service):
)
versions = dao_get_template_versions(service_id=sample_template.service_id, template_id=sample_template.id)
assert len(versions) == 0
@pytest.mark.parametrize("template_type,postage", [('letter', 'third'), ('sms', 'second')])
def test_template_postage_constraint_on_create(sample_service, sample_user, template_type, postage):
data = {
'name': 'Sample Template',
'template_type': template_type,
'content': "Template content",
'service': sample_service,
'created_by': sample_user,
'postage': postage
}
template = Template(**data)
with pytest.raises(expected_exception=SQLAlchemyError):
dao_create_template(template)
def test_template_postage_constraint_on_update(sample_service, sample_user):
data = {
'name': 'Sample Template',
'template_type': "letter",
'content': "Template content",
'service': sample_service,
'created_by': sample_user,
'postage': 'second'
}
template = Template(**data)
dao_create_template(template)
created = dao_get_all_templates_for_service(sample_service.id)[0]
assert created.name == 'Sample Template'
created.postage = 'third'
with pytest.raises(expected_exception=SQLAlchemyError):
dao_update_template(created)