def test_request_cache_control_disobedience(self): c = SimpleCache() cfg = Config(request_controls_cache=False) s = Store(c, cfg) r = Retrieval(c, cfg) with a.test_request_context('/foo', headers=(('cache-control', 'no-store'), )): self.assertTrue(r.should_fetch_response()) with a.test_request_context('/foo', headers=(('cache-control', 'no-store'), )): self.assertTrue(s.should_cache_response(Response())) with a.test_request_context('/foo', headers=(('cache-control', 'no-store'), )): self.assertTrue(s.should_cache_response(Response())) resp = Response() resp.date = datetime.utcnow() - timedelta(seconds=100) resp.cache_control.max_age = 200 with a.test_request_context('/foo', headers=(('cache-control', 'min-fresh=150'), )): f = self.r.response_freshness_seconds(resp) try: r.verify_response_freshness_or_miss(resp, f) except CacheMiss: self.fail( 'unexpected CacheMiss when ignoring request cache control')
def setUp(self): self.recached = False def dispatcher(salt): self.recached = True self.c = SimpleCache() cfg = Config(preemptive_recache_seconds=10, preemptive_recache_callback=dispatcher) self.s = Store(self.c, cfg) self.r = Retrieval(self.c, cfg)
def setUp(self): self.c = SimpleCache() self.s = Store(self.c) self.r = Retrieval(self.c)
def mkretr(**kwargs): return Retrieval(self.c, Config(**kwargs))