Beispiel #1
0
 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
Beispiel #2
0
 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
Beispiel #3
0
 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
Beispiel #4
0
 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
Beispiel #5
0
    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()
Beispiel #6
0
    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()
Beispiel #7
0
    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
Beispiel #8
0
    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
Beispiel #9
0
 def sess(self, server):
     self.url = urljoin(server.application_url, '/vary_accept')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache)
     return sess
Beispiel #10
0
 def sess(self, server):
     self.url = urljoin(server.application_url, '/vary_accept')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache)
     return sess
Beispiel #11
0
 def sess(self, url):
     self.url = urljoin(url, "/vary_accept")
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache)
     return sess
Beispiel #12
0
 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
Beispiel #13
0
 def sess(self, url):
     self.url = urljoin(url, '/vary_accept')
     self.cache = DictCache()
     sess = CacheControl(requests.Session(), cache=self.cache)
     return sess