Skip to content
This repository
Browse code

Added a test wrt cache invalidation.

  • Loading branch information...
commit 9dc756919617624fe599af4ead7cb75184b904ba 1 parent 25b8225
Jannis Leidel authored

Showing 1 changed file with 15 additions and 0 deletions. Show diff stats Hide diff stats

  1. +15 0 staticfiles/tests/tests.py
15 staticfiles/tests/tests.py
@@ -444,6 +444,21 @@ def test_template_tag_url(self):
444 444 with storage.staticfiles_storage.open(relpath) as relfile:
445 445 self.assertIn("https://", relfile.read())
446 446
  447 + def test_cache_invalidation(self):
  448 + name = "cached/styles.css"
  449 + hashed_name = "cached/styles.93b1147e8552.css"
  450 + # check if the cache is filled correctly as expected
  451 + cache_key = storage.staticfiles_storage.cache_key(name)
  452 + cached_name = storage.staticfiles_storage.cache.get(cache_key)
  453 + self.assertEqual(self.cached_file_path(name), cached_name)
  454 + # clearing the cache to make sure we re-set it correctly in the url method
  455 + storage.staticfiles_storage.cache.clear()
  456 + cached_name = storage.staticfiles_storage.cache.get(cache_key)
  457 + self.assertEqual(cached_name, None)
  458 + self.assertEqual(self.cached_file_path(name), hashed_name)
  459 + cached_name = storage.staticfiles_storage.cache.get(cache_key)
  460 + self.assertEqual(cached_name, hashed_name)
  461 +
447 462 def test_post_processing(self):
448 463 """Test that post_processing behaves correctly.
449 464

0 comments on commit 9dc7569

Please sign in to comment.
Something went wrong with that request. Please try again.