summaryrefslogtreecommitdiff
path: root/tests/cache
diff options
context:
space:
mode:
authorDaniel Fairhead <danthedeckie@gmail.com>2019-09-11 22:12:35 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-09-18 14:53:05 +0200
commit5cb3ed187b283059589cb442c56a66a795800cac (patch)
treee88967b15e1656c326762a7ab5ada770b91aaf35 /tests/cache
parent6c9778a58e4f680db180d4cc9dc5639d2ec1b40c (diff)
Fixed #30772 -- Optimized make_template_fragment_key().
Removed usage of urllib.quote(), unnecessary since cbbe60c7fc39fa8ff75554bd90104eaad6924bb1. Used hasher's .update() on key fragments.
Diffstat (limited to 'tests/cache')
-rw-r--r--tests/cache/tests.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index 871b1498aa..ec515a297b 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -2306,15 +2306,27 @@ class TestMakeTemplateFragmentKey(SimpleTestCase):
def test_with_one_vary_on(self):
key = make_template_fragment_key('foo', ['abc'])
- self.assertEqual(key, 'template.cache.foo.900150983cd24fb0d6963f7d28e17f72')
+ self.assertEqual(key, 'template.cache.foo.493e283d571a73056196f1a68efd0f66')
def test_with_many_vary_on(self):
key = make_template_fragment_key('bar', ['abc', 'def'])
- self.assertEqual(key, 'template.cache.bar.4b35f12ab03cec09beec4c21b2d2fa88')
+ self.assertEqual(key, 'template.cache.bar.17c1a507a0cb58384f4c639067a93520')
def test_proper_escaping(self):
key = make_template_fragment_key('spam', ['abc:def%'])
- self.assertEqual(key, 'template.cache.spam.f27688177baec990cdf3fbd9d9c3f469')
+ self.assertEqual(key, 'template.cache.spam.06c8ae8e8c430b69fb0a6443504153dc')
+
+ def test_with_ints_vary_on(self):
+ key = make_template_fragment_key('foo', [1, 2, 3, 4, 5])
+ self.assertEqual(key, 'template.cache.foo.7ae8fd2e0d25d651c683bdeebdb29461')
+
+ def test_with_unicode_vary_on(self):
+ key = make_template_fragment_key('foo', ['42ยบ', '๐Ÿ˜€'])
+ self.assertEqual(key, 'template.cache.foo.7ced1c94e543668590ba39b3c08b0237')
+
+ def test_long_vary_on(self):
+ key = make_template_fragment_key('foo', ['x' * 10000])
+ self.assertEqual(key, 'template.cache.foo.3670b349b5124aa56bdb50678b02b23a')
class CacheHandlerTest(SimpleTestCase):