1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Added more tests for @cache_control decorator.

This commit is contained in:
Ben Lomax 2023-04-21 13:23:05 +02:00 committed by Mariusz Felisiak
parent c24cd6575f
commit a14ddc8cfc

View File

@ -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):