def test_middleware(self):
     mw = HttpCacheMiddleware(self._get_settings(), self.crawler.stats)
     assert mw.process_request(self.request, self.spider) is None
     mw.process_response(self.request, self.response, self.spider)
     response = mw.process_request(self.request, self.spider)
     assert isinstance(response, HtmlResponse)
     self.assertEqualResponse(self.response, response)
     assert 'cached' in response.flags
Beispiel #2
0
 def test_middleware(self):
     mw = HttpCacheMiddleware(self._get_settings(), self.crawler.stats)
     assert mw.process_request(self.request, self.spider) is None
     mw.process_response(self.request, self.response, self.spider)
     response = mw.process_request(self.request, self.spider)
     assert isinstance(response, HtmlResponse)
     self.assertEqualResponse(self.response, response)
     assert 'cached' in response.flags
 def test_different_request_response_urls(self):
     mw = HttpCacheMiddleware(self._get_settings(), self.crawler.stats)
     req = Request('http://host.com/path')
     res = Response('http://host2.net/test.html')
     assert mw.process_request(req, self.spider) is None
     mw.process_response(req, res, self.spider)
     cached = mw.process_request(req, self.spider)
     assert isinstance(cached, Response)
     self.assertEqualResponse(res, cached)
     assert 'cached' in cached.flags
Beispiel #4
0
 def test_different_request_response_urls(self):
     mw = HttpCacheMiddleware(self._get_settings(), self.crawler.stats)
     req = Request('http://host.com/path')
     res = Response('http://host2.net/test.html')
     assert mw.process_request(req, self.spider) is None
     mw.process_response(req, res, self.spider)
     cached = mw.process_request(req, self.spider)
     assert isinstance(cached, Response)
     self.assertEqualResponse(res, cached)
     assert 'cached' in cached.flags