summaryrefslogtreecommitdiff
path: root/tests/regressiontests/staticfiles_tests/tests.py
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2012-03-12 20:28:09 +0000
committerJannis Leidel <jannis@leidel.info>2012-03-12 20:28:09 +0000
commit3a5f9cd1ae8a2c7101f141d9730878abb74ec92f (patch)
tree46660c72cc9302cdffb4baeea7a9b5b5ac89e986 /tests/regressiontests/staticfiles_tests/tests.py
parentebc6fc9354c857bc0ac00895175c2575b01b1bd7 (diff)
Fixed #17861 -- Took care of special characters when creating the staticfiles storage cache keys. Many thanks to Preston Holmes.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17688 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/staticfiles_tests/tests.py')
-rw-r--r--tests/regressiontests/staticfiles_tests/tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py
index fc489b33c3..7850b44b77 100644
--- a/tests/regressiontests/staticfiles_tests/tests.py
+++ b/tests/regressiontests/staticfiles_tests/tests.py
@@ -7,10 +7,12 @@ import posixpath
import shutil
import sys
import tempfile
+import warnings
from StringIO import StringIO
from django.template import loader, Context
from django.conf import settings
+from django.core.cache.backends.base import BaseCache, CacheKeyWarning
from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import default_storage
from django.core.management import call_command
@@ -498,6 +500,20 @@ class TestCollectionCachedStorage(BaseCollectionTestCase,
self.assertTrue(os.path.join('cached', 'css', 'window.css') in stats['post_processed'])
self.assertTrue(os.path.join('cached', 'css', 'img', 'window.png') in stats['unmodified'])
+ def test_cache_key_memcache_validation(self):
+ """
+ Handle cache key creation correctly, see #17861.
+ """
+ name = "/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/" + chr(22) + chr(180)
+ cache_key = storage.staticfiles_storage.cache_key(name)
+ self.save_warnings_state()
+ cache_validator = BaseCache({})
+ warnings.filterwarnings('error', category=CacheKeyWarning)
+ cache_validator.validate_key(cache_key)
+ self.restore_warnings_state()
+ self.assertEqual(cache_key, 'staticfiles:e95bbc36387084582df2a70750d7b351')
+
+
# we set DEBUG to False here since the template tag wouldn't work otherwise
TestCollectionCachedStorage = override_settings(**dict(TEST_SETTINGS,
STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',