mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Step 1 of renaming cache keys for templates
We want to change cache keys for templates and broadcasts to include
their service ID. So cache keys should change from
`template-{template_id}-versions` to
`service-{service_id}-template-{template_id}-versions`.
The first step of this which needs to be deployed as a change first is
to delete both keys when updating service templates (even if they key is
not yet set). This means that when we release code in the next PR to
start setting the new key, we won't run into a case where either the old
or the new key can remain set with stale data.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from unittest.mock import call
|
||||
|
||||
from app.notify_client.broadcast_message_api_client import (
|
||||
BroadcastMessageAPIClient,
|
||||
)
|
||||
@@ -70,7 +72,10 @@ def test_update_broadcast_message(mocker):
|
||||
'/service/12345/broadcast-message/67890',
|
||||
data={'abc': 'def'},
|
||||
)
|
||||
mock_redis_delete.assert_called_once_with('broadcast-message-67890')
|
||||
mock_redis_delete.assert_has_calls([
|
||||
call('service-12345-broadcast-message-67890'),
|
||||
call('broadcast-message-67890'),
|
||||
])
|
||||
|
||||
|
||||
def test_update_broadcast_message_status(mocker):
|
||||
@@ -89,4 +94,7 @@ def test_update_broadcast_message_status(mocker):
|
||||
'/service/12345/broadcast-message/67890/status',
|
||||
data={'created_by': '1', 'status': 'cancelled'},
|
||||
)
|
||||
mock_redis_delete.assert_called_once_with('broadcast-message-67890')
|
||||
mock_redis_delete.assert_has_calls([
|
||||
call('service-12345-broadcast-message-67890'),
|
||||
call('broadcast-message-67890'),
|
||||
])
|
||||
|
||||
@@ -435,26 +435,36 @@ def test_deletes_service_cache(
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
]),
|
||||
('update_service_template', [FAKE_TEMPLATE_ID, 'foo', 'sms', 'bar', SERVICE_ONE_ID], [
|
||||
'service-{}-template-{}-versions'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'service-{}-template-{}-version-None'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'template-{}-versions'.format(FAKE_TEMPLATE_ID),
|
||||
'template-{}-version-None'.format(FAKE_TEMPLATE_ID),
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
]),
|
||||
('redact_service_template', [SERVICE_ONE_ID, FAKE_TEMPLATE_ID], [
|
||||
'service-{}-template-{}-versions'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'service-{}-template-{}-version-None'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'template-{}-versions'.format(FAKE_TEMPLATE_ID),
|
||||
'template-{}-version-None'.format(FAKE_TEMPLATE_ID),
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
]),
|
||||
('update_service_template_sender', [SERVICE_ONE_ID, FAKE_TEMPLATE_ID, 'foo'], [
|
||||
'service-{}-template-{}-versions'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'service-{}-template-{}-version-None'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'template-{}-versions'.format(FAKE_TEMPLATE_ID),
|
||||
'template-{}-version-None'.format(FAKE_TEMPLATE_ID),
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
]),
|
||||
('update_service_template_postage', [SERVICE_ONE_ID, FAKE_TEMPLATE_ID, 'first'], [
|
||||
'service-{}-template-{}-versions'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'service-{}-template-{}-version-None'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'template-{}-versions'.format(FAKE_TEMPLATE_ID),
|
||||
'template-{}-version-None'.format(FAKE_TEMPLATE_ID),
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
]),
|
||||
('delete_service_template', [SERVICE_ONE_ID, FAKE_TEMPLATE_ID], [
|
||||
'service-{}-template-{}-versions'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'service-{}-template-{}-version-None'.format(SERVICE_ONE_ID, FAKE_TEMPLATE_ID),
|
||||
'template-{}-versions'.format(FAKE_TEMPLATE_ID),
|
||||
'template-{}-version-None'.format(FAKE_TEMPLATE_ID),
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
|
||||
Reference in New Issue
Block a user