Use cached property from werkzeug.utils

This means we can have a method on the service model which hits the API
(or Redis) but can be called multiple times (within the context of a
request) without making multiple network requests.

It does this by storing the results of the method on the object’s
internal `__dict__` the first time the method is called.
This commit is contained in:
Chris Hill-Scott
2018-10-26 11:47:42 +01:00
parent b48305c50d
commit 780b9bb715
2 changed files with 7 additions and 6 deletions

View File

@@ -131,7 +131,7 @@ def test_should_show_page_for_choosing_a_template(
for index, expected_template in enumerate(expected_templates):
assert template_links[index].text.strip() == expected_template
mock_get_service_templates.assert_called_with(SERVICE_ONE_ID)
mock_get_service_templates.assert_called_once_with(SERVICE_ONE_ID)
def test_should_not_show_template_nav_if_only_one_type_of_template(