From dddb2af31e95e3db5d2568a4ead8d3a38f38fc61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Tue, 16 May 2017 11:55:40 +0200 Subject: [PATCH 1/3] Fix JSONDecode error on get_records_timestamp call. --- kinto_http/session.py | 3 +-- kinto_http/tests/functional.py | 10 ++++++++++ kinto_http/tests/test_client.py | 3 +-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kinto_http/session.py b/kinto_http/session.py index d33f6a5..78a3e82 100644 --- a/kinto_http/session.py +++ b/kinto_http/session.py @@ -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 diff --git a/kinto_http/tests/functional.py b/kinto_http/tests/functional.py index c5c806b..efeb64e 100644 --- a/kinto_http/tests/functional.py +++ b/kinto_http/tests/functional.py @@ -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') diff --git a/kinto_http/tests/test_client.py b/kinto_http/tests/test_client.py index 667eaab..b7ecdef 100644 --- a/kinto_http/tests/test_client.py +++ b/kinto_http/tests/test_client.py @@ -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' From d30012e7aba02700146e26afa4cd6fe1f8aff7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Tue, 16 May 2017 11:57:02 +0200 Subject: [PATCH 2/3] Update changelog. --- CHANGELOG.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d941a29..44987c8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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) From e6dd2ab0ef937a00c24a54f6155fdc0fa1daeea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Tue, 16 May 2017 12:00:20 +0200 Subject: [PATCH 3/3] Fix flush endpoint config. --- kinto_http/tests/config/kinto.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kinto_http/tests/config/kinto.ini b/kinto_http/tests/config/kinto.ini index 21752c5..7e19b29 100644 --- a/kinto_http/tests/config/kinto.ini +++ b/kinto_http/tests/config/kinto.ini @@ -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