Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSONDecode error on get_records_timestamp call. #144

Merged
merged 3 commits into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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