From 5b0cc8819abc878063d9195875d46e11a1a7df95 Mon Sep 17 00:00:00 2001 From: David McDonald Date: Mon, 21 Sep 2020 17:16:33 +0100 Subject: [PATCH] Use new redis key for templates Equivalent of https://github.com/alphagov/notifications-admin/pull/3639 but for the API. This is the only place in the API we appear to be getting setting templates or broadcast messages. --- app/serialised_models.py | 2 +- tests/app/v2/notifications/test_post_notifications.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/serialised_models.py b/app/serialised_models.py index 1b17726f0..295b298ad 100644 --- a/app/serialised_models.py +++ b/app/serialised_models.py @@ -55,7 +55,7 @@ class SerialisedTemplate(SerialisedModel): return cls(cls.get_dict(template_id, service_id)['data']) @staticmethod - @redis_cache.set('template-{template_id}-version-None') + @redis_cache.set('service-{service_id}-template-{template_id}-version-None') def get_dict(template_id, service_id): from app.dao import templates_dao from app.schemas import template_schema diff --git a/tests/app/v2/notifications/test_post_notifications.py b/tests/app/v2/notifications/test_post_notifications.py index bdb33b7bc..5e3738155 100644 --- a/tests/app/v2/notifications/test_post_notifications.py +++ b/tests/app/v2/notifications/test_post_notifications.py @@ -264,7 +264,7 @@ def test_should_cache_template_and_service_in_redis(mocker, client, sample_templ ) expected_service_key = f'service-{sample_template.service_id}' - expected_templates_key = f'template-{sample_template.id}-version-None' + expected_templates_key = f'service-{sample_template.service_id}-template-{sample_template.id}-version-None' assert mock_redis_get.call_args_list == [ call(expected_service_key),