Delete service cache when changing an organisation's sector

When we change an organisation's sector we now also change the sector of
all its services, so we need to delete those services from Redis.
This commit is contained in:
Katie Smith
2019-07-24 11:57:42 +01:00
parent eb7504bc0d
commit dc1c73c647
4 changed files with 99 additions and 5 deletions

View File

@@ -359,17 +359,17 @@ def test_view_organisation_settings(
(
'.edit_organisation_type',
{'organisation_type': 'central'},
{'organisation_type': 'central'},
{'cached_service_ids': [], 'organisation_type': 'central'},
),
(
'.edit_organisation_type',
{'organisation_type': 'local'},
{'organisation_type': 'local'},
{'cached_service_ids': [], 'organisation_type': 'local'},
),
(
'.edit_organisation_type',
{'organisation_type': 'nhs_local'},
{'organisation_type': 'nhs_local'},
{'cached_service_ids': [], 'organisation_type': 'nhs_local'},
),
(
'.edit_organisation_crown_status',
@@ -412,6 +412,7 @@ def test_view_organisation_settings(
),
))
def test_update_organisation_settings(
mocker,
client_request,
fake_uuid,
organisation_one,
@@ -422,6 +423,7 @@ def test_update_organisation_settings(
expected_persisted,
user,
):
mocker.patch('app.organisations_client.get_organisation_services', return_value=[])
client_request.login(user(fake_uuid))
client_request.post(
@@ -442,6 +444,35 @@ def test_update_organisation_settings(
)
def test_update_organisation_sector_sends_service_id_data_to_api_client(
client_request,
mock_get_organisation,
organisation_one,
mock_get_organisation_services,
mock_update_organisation,
platform_admin_user,
):
client_request.login(platform_admin_user)
client_request.post(
'main.edit_organisation_type',
org_id=organisation_one['id'],
_data={'organisation_type': 'central'},
_expected_status=302,
_expected_redirect=url_for(
'main.organisation_settings',
org_id=organisation_one['id'],
_external=True,
),
)
mock_update_organisation.assert_called_once_with(
organisation_one['id'],
cached_service_ids=['12345', '67890', SERVICE_ONE_ID],
organisation_type='central'
)
@pytest.mark.parametrize('user', (
pytest.param(
platform_admin_user,