diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 865f0cefc80..c26183f5b25 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -2083,6 +2083,7 @@ class CacheMiddlewareTest(SimpleTestCase): self.assertEqual(middleware.cache_timeout, 30) self.assertEqual(middleware.key_prefix, 'middlewareprefix') self.assertEqual(middleware.cache_alias, 'other') + self.assertEqual(middleware.cache, self.other_cache) # If more arguments are being passed in construction, it's being used # as a decorator. First, test with "defaults": @@ -2092,6 +2093,7 @@ class CacheMiddlewareTest(SimpleTestCase): self.assertEqual(as_view_decorator.key_prefix, '') # Value of DEFAULT_CACHE_ALIAS from django.core.cache self.assertEqual(as_view_decorator.cache_alias, 'default') + self.assertEqual(as_view_decorator.cache, self.default_cache) # Next, test with custom values: as_view_decorator_with_custom = CacheMiddleware( @@ -2101,6 +2103,21 @@ class CacheMiddlewareTest(SimpleTestCase): self.assertEqual(as_view_decorator_with_custom.cache_timeout, 60) self.assertEqual(as_view_decorator_with_custom.key_prefix, 'foo') self.assertEqual(as_view_decorator_with_custom.cache_alias, 'other') + self.assertEqual(as_view_decorator_with_custom.cache, self.other_cache) + + def test_update_cache_middleware_constructor(self): + middleware = UpdateCacheMiddleware(empty_response) + self.assertEqual(middleware.cache_timeout, 30) + self.assertIsNone(middleware.page_timeout) + self.assertEqual(middleware.key_prefix, 'middlewareprefix') + self.assertEqual(middleware.cache_alias, 'other') + self.assertEqual(middleware.cache, self.other_cache) + + def test_fetch_cache_middleware_constructor(self): + middleware = FetchFromCacheMiddleware(empty_response) + self.assertEqual(middleware.key_prefix, 'middlewareprefix') + self.assertEqual(middleware.cache_alias, 'other') + self.assertEqual(middleware.cache, self.other_cache) def test_middleware(self): middleware = CacheMiddleware(hello_world_view)