MCPcopy
hub / github.com/django/django / test_get_cache_key

Method test_get_cache_key

tests/cache/tests.py:3018–3039  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3016 self.assertEqual(response.headers["Vary"], resulting_vary)
3017
3018 def test_get_cache_key(self):
3019 request = self.factory.get(self.path)
3020 template = engines["django"].from_string("This is a test")
3021 response = TemplateResponse(HttpRequest(), template)
3022 key_prefix = "localprefix"
3023 # Expect None if no headers have been set yet.
3024 self.assertIsNone(get_cache_key(request))
3025 # Set headers to an empty list.
3026 learn_cache_key(request, response)
3027
3028 self.assertEqual(
3029 get_cache_key(request),
3030 "views.decorators.cache.cache_page.settingsprefix.GET."
3031 "58a0a05c8a5620f813686ff969c26853.d41d8cd98f00b204e9800998ecf8427e",
3032 )
3033 # A specified key_prefix is taken into account.
3034 learn_cache_key(request, response, key_prefix=key_prefix)
3035 self.assertEqual(
3036 get_cache_key(request, key_prefix=key_prefix),
3037 "views.decorators.cache.cache_page.localprefix.GET."
3038 "58a0a05c8a5620f813686ff969c26853.d41d8cd98f00b204e9800998ecf8427e",
3039 )
3040
3041 def test_get_cache_key_with_query(self):
3042 request = self.factory.get(self.path, {"test": 1})

Callers

nothing calls this directly

Calls 6

TemplateResponseClass · 0.90
HttpRequestClass · 0.90
get_cache_keyFunction · 0.90
learn_cache_keyFunction · 0.90
getMethod · 0.45
from_stringMethod · 0.45

Tested by

no test coverage detected