summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-11-02 17:45:32 +0000
committerJannis Leidel <jannis@leidel.info>2011-11-02 17:45:32 +0000
commit0e2c543979dfd06a40c1b34a6fb8eda2e92c8771 (patch)
treee76901f1a4831c52f845e72b8b66ec5304727f65 /tests
parent44a4037466f3f2db02ce191f05faa3230c17e910 (diff)
Fixed #16967 -- Made sure CachedStaticFilesStorage repopulates its cache if there was a miss (for example if the cache server went down).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17067 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-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 f12914f642..67977e70d1 100644
--- a/tests/regressiontests/staticfiles_tests/tests.py
+++ b/tests/regressiontests/staticfiles_tests/tests.py
@@ -352,6 +352,22 @@ class TestCollectionCachedStorage(BaseCollectionTestCase,
with storage.staticfiles_storage.open(relpath) as relfile:
self.assertTrue("https://" in relfile.read())
+ def test_cache_invalidation(self):
+ name = "cached/styles.css"
+ hashed_name = "cached/styles.93b1147e8552.css"
+ # check if the cache is filled correctly as expected
+ cache_key = storage.staticfiles_storage.cache_key(name)
+ cached_name = storage.staticfiles_storage.cache.get(cache_key)
+ self.assertEqual(self.cached_file_path(name), cached_name)
+ # clearing the cache to make sure we re-set it correctly in the url method
+ storage.staticfiles_storage.cache.clear()
+ cached_name = storage.staticfiles_storage.cache.get(cache_key)
+ self.assertEqual(cached_name, None)
+ self.assertEqual(self.cached_file_path(name), hashed_name)
+ cached_name = storage.staticfiles_storage.cache.get(cache_key)
+ self.assertEqual(cached_name, hashed_name)
+
+
# 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',