def sess(self, server): self.etag_url = urljoin(server.application_url, '/etag') self.update_etag_url = urljoin(server.application_url, '/update_etag') self.cache = DictCache() sess = CacheControl(requests.Session(), cache=self.cache, cache_etags=False) return sess
def sess(self, server, url): self.etag_url = urljoin(url, '/etag') self.update_etag_url = urljoin(url, '/update_etag') self.cache = DictCache() sess = CacheControl(requests.Session(), cache=self.cache, cache_etags=False, serializer=NullSerializer()) return sess
def sess(self, url): self.etag_url = urljoin(url, "/etag") self.update_etag_url = urljoin(url, "/update_etag") self.cache = DictCache() sess = CacheControl( requests.Session(), cache=self.cache, serializer=NullSerializer() ) yield sess # closing session object sess.close()
def sess(self, url): self.etag_url = urljoin(url, "/etag") self.update_etag_url = urljoin(url, "/update_etag") self.cache = DictCache() sess = CacheControl(requests.Session(), cache=self.cache, serializer=NullSerializer()) yield sess # closing session object sess.close()
def test_not_modified_releases_connection(self, server): sess = CacheControl(requests.Session()) etag_url = urljoin(server.application_url, '/etag') sess.get(etag_url) resp = Mock(status=304, headers={}) # This is how the urllib3 response is created in # requests.adapters response_mod = 'requests.adapters.HTTPResponse.from_httplib' with patch(response_mod, Mock(return_value=resp)): sess.get(etag_url) assert resp.read.called assert resp.release_conn.called
def test_not_modified_releases_connection(self, server): sess = CacheControl(requests.Session()) etag_url = urljoin(server.application_url, "/etag") sess.get(etag_url) resp = Mock(status=304, headers={}) # This is how the urllib3 response is created in # requests.adapters response_mod = "requests.adapters.HTTPResponse.from_httplib" with patch(response_mod, Mock(return_value=resp)): sess.get(etag_url) assert resp.read.called assert resp.release_conn.called
def sess(self, server): self.url = urljoin(server.application_url, '/vary_accept') self.cache = DictCache() sess = CacheControl(requests.Session(), cache=self.cache) return sess
def sess(self, url): self.url = urljoin(url, "/vary_accept") self.cache = DictCache() sess = CacheControl(requests.Session(), cache=self.cache) return sess
def sess(self, server): self.etag_url = urljoin(server.application_url, "/etag") self.update_etag_url = urljoin(server.application_url, "/update_etag") self.cache = DictCache() sess = CacheControl(requests.Session(), cache=self.cache, cache_etags=False, serializer=NullSerializer()) return sess
def sess(self, url): self.url = urljoin(url, '/vary_accept') self.cache = DictCache() sess = CacheControl(requests.Session(), cache=self.cache) return sess