diff options
author | Tom Carrick <tom@carrick.eu> | 2020-07-14 13:32:24 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-09-14 08:41:59 +0200 |
commit | bcc2befd0e9c1885e45b46d0b0bcdc11def8b249 (patch) | |
tree | 59fab69a3182286da87fcd6fe05a8ce0f4277a5a /tests/cache | |
parent | 71ae1ab0123582cc5bfe0f7d5f4cc19a9412f396 (diff) | |
download | django-bcc2befd0e9c1885e45b46d0b0bcdc11def8b249.tar.gz |
Fixed #31789 -- Added a new headers interface to HttpResponse.
Diffstat (limited to 'tests/cache')
-rw-r--r-- | tests/cache/tests.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 93f0d87ecb..1c51c38b2b 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -1700,9 +1700,9 @@ class CacheUtils(SimpleTestCase): with self.subTest(initial_vary=initial_vary, newheaders=newheaders): response = HttpResponse() if initial_vary is not None: - response['Vary'] = initial_vary + response.headers['Vary'] = initial_vary patch_vary_headers(response, newheaders) - self.assertEqual(response['Vary'], resulting_vary) + self.assertEqual(response.headers['Vary'], resulting_vary) def test_get_cache_key(self): request = self.factory.get(self.path) @@ -1753,7 +1753,7 @@ class CacheUtils(SimpleTestCase): def test_learn_cache_key(self): request = self.factory.head(self.path) response = HttpResponse() - response['Vary'] = 'Pony' + response.headers['Vary'] = 'Pony' # Make sure that the Vary header is added to the key hash learn_cache_key(request, response) @@ -1795,9 +1795,9 @@ class CacheUtils(SimpleTestCase): with self.subTest(initial_cc=initial_cc, newheaders=newheaders): response = HttpResponse() if initial_cc is not None: - response['Cache-Control'] = initial_cc + response.headers['Cache-Control'] = initial_cc patch_cache_control(response, **newheaders) - parts = set(cc_delim_re.split(response['Cache-Control'])) + parts = set(cc_delim_re.split(response.headers['Cache-Control'])) self.assertEqual(parts, expected_cc) @@ -1892,7 +1892,7 @@ class CacheI18nTest(SimpleTestCase): request.META['HTTP_ACCEPT_LANGUAGE'] = accept_language request.META['HTTP_ACCEPT_ENCODING'] = 'gzip;q=1.0, identity; q=0.5, *;q=0' response = HttpResponse() - response['Vary'] = vary + response.headers['Vary'] = vary key = learn_cache_key(request, response) key2 = get_cache_key(request) self.assertEqual(key, reference_key) @@ -1905,7 +1905,7 @@ class CacheI18nTest(SimpleTestCase): request = self.factory.get(self.path) request.META['HTTP_ACCEPT_ENCODING'] = 'gzip;q=1.0, identity; q=0.5, *;q=0' response = HttpResponse() - response['Vary'] = 'accept-encoding' + response.headers['Vary'] = 'accept-encoding' key = learn_cache_key(request, response) self.assertIn(lang, key, "Cache keys should include the language name when translation is active") self.check_accept_language_vary( @@ -2364,9 +2364,9 @@ class TestWithTemplateResponse(SimpleTestCase): template = engines['django'].from_string("This is a test") response = TemplateResponse(HttpRequest(), template) if initial_vary is not None: - response['Vary'] = initial_vary + response.headers['Vary'] = initial_vary patch_vary_headers(response, newheaders) - self.assertEqual(response['Vary'], resulting_vary) + self.assertEqual(response.headers['Vary'], resulting_vary) def test_get_cache_key(self): request = self.factory.get(self.path) |