Skip to content

Commit

Permalink
Merge pull request #144 from Kinto/get_records_timestamp_json_decode_…
Browse files Browse the repository at this point in the history
…error

Fix JSONDecode error on get_records_timestamp call.
  • Loading branch information
Natim authored May 16, 2017
2 parents 8d9cd6c + e6dd2ab commit a77e621
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ CHANGELOG
This document describes changes between each past release.


8.1.0 (unreleased)
8.0.1 (unreleased)
==================

- Nothing changed yet.
**Bug fixes**

- Fix get_records_timestamp JSONDecode error while trying to decode
the body of a HEAD response. (#144)


8.0.0 (2017-05-11)
Expand Down
3 changes: 1 addition & 2 deletions kinto_http/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ def request(self, method, endpoint, data=None, permissions=None,
exception.response = resp
raise exception

if resp.status_code == 304:
if resp.status_code == 304 or method == 'head':
body = None
else:
body = resp.json()
# XXX Add the status code.
return body, resp.headers
3 changes: 2 additions & 1 deletion kinto_http/tests/config/kinto.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
use = egg:kinto

kinto.userid_hmac_secret = b4c96a8d91846eb4692291d88fe5a97d
kinto.flush_endpoint_enabled = true
kinto.paginate_by = 5

kinto.includes = kinto.plugins.flush

[server:main]
use = egg:waitress#main
host = 0.0.0.0
Expand Down
10 changes: 10 additions & 0 deletions kinto_http/tests/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ def test_records_list_retrieval(self):
records = client.get_records()
assert len(records) == 1

def test_records_timestamp_retrieval(self):
client = Client(server_url=self.server_url, auth=self.auth,
bucket='mozilla', collection='payments')
client.create_bucket()
client.create_collection()
record = client.create_record(data={'foo': 'bar'},
permissions={'read': ['alexis']})
etag = client.get_records_timestamp()
assert str(etag) == str(record["data"]["last_modified"])

def test_records_paginated_list_retrieval(self):
client = Client(server_url=self.server_url, auth=self.auth,
bucket='mozilla', collection='payments')
Expand Down
3 changes: 1 addition & 2 deletions kinto_http/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,7 @@ def test_collection_can_retrieve_all_records(self):
assert list(records) == [{'id': 'foo'}, {'id': 'bar'}]

def test_collection_can_retrieve_records_timestamp(self):
mock_response(self.session, data=[{'id': 'foo'}, {'id': 'bar'}],
headers={"ETag": '"12345"'})
mock_response(self.session, headers={"ETag": '"12345"'})
timestamp = self.client.get_records_timestamp()
assert timestamp == '12345'

Expand Down

0 comments on commit a77e621

Please sign in to comment.