示例#1
0
 def test_reset_empties_the_requests_cache(self):
     batch = Batch(self.client)
     batch.request('GET', '/foobar/baz',
                   permissions=mock.sentinel.permissions)
     assert len(batch.requests) == 1
     batch.reset()
     assert len(batch.requests) == 0
示例#2
0
 def test_reset_empties_the_requests_cache(self):
     batch = Batch(self.client)
     batch.request('GET',
                   '/foobar/baz',
                   permissions=mock.sentinel.permissions)
     assert len(batch.requests) == 1
     batch.reset()
     assert len(batch.requests) == 0
示例#3
0
    def batch(self, **kwargs):
        if self._server_settings is None:
            resp, _ = self.session.request("GET", self._get_endpoint('root'))
            self._server_settings = resp['settings']

        batch_max_requests = self._server_settings['batch_max_requests']
        batch_session = Batch(self, batch_max_requests=batch_max_requests)
        batch_client = self.clone(session=batch_session, **kwargs)
        yield batch_client
        batch_session.send()
        batch_session.reset()
示例#4
0
    def batch(self, **kwargs):
        if self._server_settings is None:
            resp, _ = self.session.request("GET", self._get_endpoint('root'))
            self._server_settings = resp['settings']

        batch_max_requests = self._server_settings['batch_max_requests']
        batch_session = Batch(self, batch_max_requests=batch_max_requests)
        batch_client = self.clone(session=batch_session, **kwargs)
        yield batch_client
        batch_session.send()
        batch_session.reset()