Fix go-live checks ignoring nested templates

This is a very low impact bug since a user can always create such
templates after their service is live and not be subject to checks
we do before that point. Still, we may as well fix it.

The main benefit of this change is actually to contribute towards
moving methods like "get_templates" out of the Service class so
we can simplify and cache their results more effectively.

Note: I wanted to simplify the Service class further as the two
"has_" properties are only used once in the app code. Unfortunately
they are tightly coupled in one of the tests as well [^1].

[^1]: bef0382cca/tests/app/main/views/service_settings/test_service_settings.py (L1961-L1962)
This commit is contained in:
Ben Thorner
2022-05-27 10:31:06 +01:00
parent 1b96a13565
commit 32efb9a03d
2 changed files with 10 additions and 26 deletions

View File

@@ -267,29 +267,7 @@ def test_service_billing_details(purchase_order_number, expected_result):
assert service.billing_details == expected_result
@pytest.mark.xfail
def test_has_email_templates_includes_folders(
mocker,
service_one,
mock_get_template_folders,
):
mocker.patch(
'app.service_api_client.get_service_templates',
return_value={'data': [create_template(
folder='something', template_type='email'
)]}
)
mocker.patch(
'app.template_folder_api_client.get_template_folders',
return_value=[create_folder(id='something')]
)
assert Service(service_one).has_email_templates
@pytest.mark.xfail
def test_has_sms_templates_includes_folders(
def test_has_templates_of_type_includes_folders(
mocker,
service_one,
mock_get_template_folders,
@@ -306,4 +284,4 @@ def test_has_sms_templates_includes_folders(
return_value=[create_folder(id='something')]
)
assert Service(service_one).has_sms_templates
assert Service(service_one).has_templates_of_type('sms')