Skip to content

Commit 72cc8ad

Browse files
committed
@Natim review
1 parent 963904a commit 72cc8ad

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VIRTUALENV = virtualenv
1+
VIRTUALENV = virtualenv --python=python3.6
22
VENV := $(shell echo $${VIRTUAL_ENV-.venv})
33
PYTHON = $(VENV)/bin/python
44
DEV_STAMP = $(VENV)/.dev_env_installed.stamp

kinto_http/batch.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def request(self, method, endpoint, data=None, permissions=None,
2828
if permissions is not None:
2929
payload['permissions'] = permissions
3030

31-
self.requests.append((method, endpoint, payload.get("data"),
32-
payload.get("permissions"), headers))
31+
self.requests.append((method, endpoint, payload, headers))
3332
# This is the signature of the session request.
3433
return defaultdict(dict), defaultdict(dict)
3534

@@ -39,17 +38,13 @@ def reset(self):
3938

4039
def _build_requests(self):
4140
requests = []
42-
for (method, url, data, permissions, headers) in self.requests:
41+
for (method, url, payload, headers) in self.requests:
4342
# Strip the prefix in batch requests.
4443
request = {
4544
'method': method.upper(),
4645
'path': url.replace('v1/', '')}
4746

48-
request['body'] = {}
49-
if data is not None:
50-
request['body']['data'] = data
51-
if permissions is not None:
52-
request['body']['permissions'] = permissions
47+
request['body'] = payload
5348
if headers is not None:
5449
request['headers'] = headers
5550
requests.append(request)

kinto_http/tests/test_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def test_context_manager_works_as_expected(self):
2626
batch.create_record(id=1234, data={'foo': 'bar'})
2727
batch.create_record(id=5678, data={'bar': 'baz'})
2828
batch.patch_record(id=5678, data={'bar': 'biz'})
29+
changes = JSONPatch([{'op': 'add', 'location': 'foo', 'value': 'bar'}])
30+
batch.patch_record(id=5678, changes=changes)
2931

3032
self.session.request.assert_called_with(
3133
method='POST',
@@ -42,7 +44,11 @@ def test_context_manager_works_as_expected(self):
4244
{'body': {'data': {'bar': 'biz'}},
4345
'path': '/buckets/mozilla/collections/test/records/5678',
4446
'method': 'PATCH',
45-
'headers': {'Content-Type': 'application/json'}}]})
47+
'headers': {'Content-Type': 'application/json'}},
48+
{'body': [{'op': 'add', 'location': 'foo', 'value': 'bar'}],
49+
'path': '/buckets/mozilla/collections/test/records/5678',
50+
'method': 'PATCH',
51+
'headers': {'Content-Type': 'application/json-patch+json'}}]})
4652

4753
def test_batch_raises_exception(self):
4854
# Make the next call to sess.request raise a 403.

0 commit comments

Comments
 (0)