Clear service cache for when updating org branding

Updating an organisation’s branding might now also update the branding
of services associated to that organisation. This is similar to how
updating an organisation’s type can update the organisation type for its
services.

In the latter case we already make sure to clear the cached version of
these services which is held in Redis.

This commit does the same clearing of the caches when updating an
organisation’s branding (and does a bit of refactoring to do so without
duplication of code.)
This commit is contained in:
Chris Hill-Scott
2019-10-03 11:57:24 +01:00
parent 8b9cc5f4dc
commit 78e57dbff9
5 changed files with 36 additions and 15 deletions

View File

@@ -361,6 +361,7 @@ def test_accept_agreement_page_validates(
agreement_signed_version=1.2,
agreement_signed_on_behalf_of_name='Firstname Lastname',
agreement_signed_on_behalf_of_email_address='test@example.com',
cached_service_ids=None,
)
),
(
@@ -375,6 +376,7 @@ def test_accept_agreement_page_validates(
agreement_signed_version=1.2,
agreement_signed_on_behalf_of_name='',
agreement_signed_on_behalf_of_email_address='',
cached_service_ids=None,
)
),
(
@@ -389,6 +391,7 @@ def test_accept_agreement_page_validates(
agreement_signed_version=1.2,
agreement_signed_on_behalf_of_name='',
agreement_signed_on_behalf_of_email_address='',
cached_service_ids=None,
)
),
))
@@ -483,6 +486,7 @@ def test_confirm_agreement_page_persists(
agreement_signed=True,
agreement_signed_at='2012-01-01 01:01:00',
agreement_signed_by_id=fake_uuid,
cached_service_ids=None,
)

View File

@@ -3196,6 +3196,7 @@ def test_service_preview_letter_branding_saves(
client_request,
platform_admin_user,
mock_get_organisation,
mock_get_organisation_services,
mock_update_service,
mock_update_organisation,
mock_get_all_letter_branding,
@@ -3229,6 +3230,11 @@ def test_service_preview_letter_branding_saves(
mock_update_organisation.assert_called_once_with(
ORGANISATION_ID,
letter_branding_id=expected_post_data,
cached_service_ids=[
'12345',
'67890',
'596364a0-858e-42c8-9062-a8fe822260eb',
],
)
assert mock_update_service.called is False
@@ -3407,6 +3413,7 @@ def test_should_set_branding_and_organisations(
platform_admin_user,
service_one,
mock_get_organisation,
mock_get_organisation_services,
mock_update_service,
mock_update_organisation,
posted_value,
@@ -3439,7 +3446,12 @@ def test_should_set_branding_and_organisations(
elif endpoint == 'main.organisation_preview_email_branding':
mock_update_organisation.assert_called_once_with(
ORGANISATION_ID,
email_branding_id=submitted_value
email_branding_id=submitted_value,
cached_service_ids=[
'12345',
'67890',
'596364a0-858e-42c8-9062-a8fe822260eb',
],
)
assert mock_update_service.called is False
else: