mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Revert "Don't return hidden templates in API service template responses"
Filtering out hidden templates requires all existing templates to have `hidden` flag set, which can only be done by a migration after the code that sets the flag to `False` by default for new templates has been released. This removes the filtering logic until the migration has been released.
This commit is contained in:
@@ -216,7 +216,6 @@ def sample_template(
|
||||
template_type="sms",
|
||||
content="This is a template:\nwith a newline",
|
||||
archived=False,
|
||||
hidden=False,
|
||||
subject_line='Subject',
|
||||
user=None,
|
||||
service=None,
|
||||
@@ -238,7 +237,6 @@ def sample_template(
|
||||
'service': service,
|
||||
'created_by': created_by,
|
||||
'archived': archived,
|
||||
'hidden': hidden,
|
||||
'process_type': process_type
|
||||
}
|
||||
if template_type in ['email', 'letter']:
|
||||
|
||||
@@ -286,29 +286,6 @@ def test_get_all_templates_ignores_archived_templates(notify_db, notify_db_sessi
|
||||
assert templates[0] == normal_template
|
||||
|
||||
|
||||
def test_get_all_templates_ignores_hidden_templates(notify_db, notify_db_session, sample_service):
|
||||
normal_template = create_sample_template(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template_name='Normal Template',
|
||||
service=sample_service,
|
||||
archived=False
|
||||
)
|
||||
|
||||
create_sample_template(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template_name='Hidden Template',
|
||||
hidden=True,
|
||||
service=sample_service
|
||||
)
|
||||
|
||||
templates = dao_get_all_templates_for_service(sample_service.id)
|
||||
|
||||
assert len(templates) == 1
|
||||
assert templates[0] == normal_template
|
||||
|
||||
|
||||
def test_get_template_by_id_and_service(notify_db, notify_db_session, sample_service):
|
||||
sample_template = create_sample_template(
|
||||
notify_db,
|
||||
@@ -324,39 +301,6 @@ def test_get_template_by_id_and_service(notify_db, notify_db_session, sample_ser
|
||||
assert not template.redact_personalisation
|
||||
|
||||
|
||||
def test_get_template_by_id_and_service_returns_none_for_hidden_templates(notify_db, notify_db_session, sample_service):
|
||||
sample_template = create_sample_template(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template_name='Test Template',
|
||||
hidden=True,
|
||||
service=sample_service
|
||||
)
|
||||
|
||||
with pytest.raises(NoResultFound):
|
||||
dao_get_template_by_id_and_service_id(
|
||||
template_id=sample_template.id,
|
||||
service_id=sample_service.id
|
||||
)
|
||||
|
||||
|
||||
def test_get_template_version_returns_none_for_hidden_templates(notify_db, notify_db_session, sample_service):
|
||||
sample_template = create_sample_template(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template_name='Test Template',
|
||||
hidden=True,
|
||||
service=sample_service
|
||||
)
|
||||
|
||||
with pytest.raises(NoResultFound):
|
||||
dao_get_template_by_id_and_service_id(
|
||||
sample_template.id,
|
||||
sample_service.id,
|
||||
'1'
|
||||
)
|
||||
|
||||
|
||||
def test_get_template_by_id_and_service_returns_none_if_no_template(sample_service, fake_uuid):
|
||||
with pytest.raises(NoResultFound) as e:
|
||||
dao_get_template_by_id_and_service_id(template_id=fake_uuid, service_id=sample_service.id)
|
||||
@@ -464,18 +408,6 @@ def test_get_template_versions(sample_template):
|
||||
assert len(v) == 2
|
||||
|
||||
|
||||
def test_get_template_versions_is_empty_for_hidden_templates(notify_db, notify_db_session, sample_service):
|
||||
sample_template = create_sample_template(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
template_name='Test Template',
|
||||
hidden=True,
|
||||
service=sample_service
|
||||
)
|
||||
versions = dao_get_template_versions(service_id=sample_template.service_id, template_id=sample_template.id)
|
||||
assert len(versions) == 0
|
||||
|
||||
|
||||
def test_get_templates_by_ids_successful(notify_db, notify_db_session):
|
||||
template_1 = create_sample_template(
|
||||
notify_db,
|
||||
|
||||
Reference in New Issue
Block a user