Ejemplo n.º 1
0
 def test_should_define_Cache_control_as_no_cache_if_the_user_is_authenticated(self):
     request = RequestFactory().get("/")
     request.user = User()
     request.user.is_authenticated = lambda: True
     m = mocks.ResponseMock()
     response = middleware.CacheMiddleware().process_response(request, m)
     self.assertEqual("no-cache", response["Cache-Control"])
Ejemplo n.º 2
0
 def test_should_add_max_age_directive_to_the_value_in_settings(self):
     request = RequestFactory().get("/")
     request.user = User()
     request.user.is_authenticated = lambda: False
     m = mocks.ResponseMock()
     response = middleware.CacheMiddleware().process_response(request, m)
     self.assertEqual("max-age=%s" % settings.PAGE_CACHE_MAXAGE, response["Cache-Control"])
Ejemplo n.º 3
0
 def test_should_remove_Vary_cookie_if_present(self):
     request = RequestFactory().get("/")
     request.user = User()
     request.user.is_authenticated = lambda: False
     m = mocks.ResponseMock()
     m["Vary"] = "Accept-Language, Cookie"
     response = middleware.CacheMiddleware().process_response(request, m)
     self.assertEqual("Accept-Language", response["Vary"])
Ejemplo n.º 4
0
 def test_should_not_touch_the_value_of_Cache_control_if_it_is_defined(self):
     request = RequestFactory().get("/")
     request.user = User()
     request.user.is_authenticated = lambda: False
     m = mocks.ResponseMock()
     m["Cache-Control"] = "no-cache"
     response = middleware.CacheMiddleware().process_response(request, m)
     self.assertEqual("no-cache", response["Cache-Control"])
Ejemplo n.º 5
0
 def test_should_not_cache_if_the_response_is_a_redirect(self):
     request = RequestFactory().get("/")
     m = mocks.ResponseMock()
     m.status_code = 301
     response = middleware.CacheMiddleware().process_response(request, m)
     self.assertEqual("no-cache", response["Cache-Control"])