Skip to content

Commit

Permalink
@almet review
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Feb 5, 2016
1 parent ef41e40 commit 9f95a33
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions kinto_client/batch.py
Expand Up @@ -51,14 +51,15 @@ def send(self):
result = []
requests = self._build_requests()
for chunk in utils.chunks(requests, self.batch_max_requests):
args = ('POST', self.endpoints.get('batch'))
kwargs = dict(payload={'requests': chunk})
kwargs = dict(method='POST',
endpoint=self.endpoints.get('batch'),
payload={'requests': chunk})

retry = self.nb_retry
while retry >= 0:
headers = {}
try:
resp, headers = self.session.request(*args, **kwargs)
resp, headers = self.session.request(**kwargs)
except KintoException as e:
if retry <= 0:
raise e
Expand Down
12 changes: 6 additions & 6 deletions kinto_client/tests/test_batch.py
Expand Up @@ -24,8 +24,8 @@ def test_send_adds_data_attribute(self):
batch.send()

self.client.session.request.assert_called_with(
'POST',
self.client.endpoints.get('batch'),
method='POST',
endpoint=self.client.endpoints.get('batch'),
payload={'requests': [{
'method': 'GET',
'path': '/foobar/baz',
Expand All @@ -40,8 +40,8 @@ def test_send_adds_permissions_attribute(self):
batch.send()

self.client.session.request.assert_called_with(
'POST',
self.client.endpoints.get('batch'),
method='POST',
endpoint=self.client.endpoints.get('batch'),
payload={'requests': [{
'method': 'GET',
'path': '/foobar/baz',
Expand All @@ -55,8 +55,8 @@ def test_send_adds_headers_if_specified(self):
batch.send()

self.client.session.request.assert_called_with(
'POST',
self.client.endpoints.get('batch'),
method='POST',
endpoint=self.client.endpoints.get('batch'),
payload={'requests': [{
'method': 'GET',
'path': '/foobar/baz',
Expand Down
4 changes: 2 additions & 2 deletions kinto_client/tests/test_client.py
Expand Up @@ -22,8 +22,8 @@ def test_context_manager_works_as_expected(self):
batch.create_record(id=5678, data={'bar': 'baz'})

self.session.request.assert_called_with(
'POST',
'/batch',
method='POST',
endpoint='/batch',
payload={'requests': [
{'body': {'data': {'foo': 'bar'}},
'path': '/buckets/mozilla/collections/test/records/1234',
Expand Down

0 comments on commit 9f95a33

Please sign in to comment.