From a14ddc8cfccbc8da6c11e1208131abc3abd6ed5d Mon Sep 17 00:00:00 2001 From: Ben Lomax Date: Fri, 21 Apr 2023 13:23:05 +0200 Subject: Added more tests for @cache_control decorator. --- tests/decorators/test_cache.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/decorators/test_cache.py b/tests/decorators/test_cache.py index 934a69e3fd..9aa224c024 100644 --- a/tests/decorators/test_cache.py +++ b/tests/decorators/test_cache.py @@ -42,6 +42,25 @@ class CacheControlDecoratorTest(SimpleTestCase): response = MyClass().a_view(HttpRequestProxy(request)) self.assertEqual(response.headers["Cache-Control"], "a=b") + def test_cache_control_empty_decorator(self): + @cache_control() + def a_view(request): + return HttpResponse() + + response = a_view(HttpRequest()) + self.assertEqual(response.get("Cache-Control"), "") + + def test_cache_control_full_decorator(self): + @cache_control(max_age=123, private=True, public=True, custom=456) + def a_view(request): + return HttpResponse() + + response = a_view(HttpRequest()) + cache_control_items = response.get("Cache-Control").split(", ") + self.assertEqual( + set(cache_control_items), {"max-age=123", "private", "public", "custom=456"} + ) + class CachePageDecoratorTest(SimpleTestCase): def test_cache_page(self): -- cgit v1.2.1