From 2bfeefb4ef4250e94228c68d461514f959c9a43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Fri, 9 Oct 2015 16:09:05 +0200 Subject: [PATCH 1/2] Allow order by oldest. --- syncclient/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syncclient/client.py b/syncclient/client.py index c01cb84..98eb1db 100644 --- a/syncclient/client.py +++ b/syncclient/client.py @@ -197,6 +197,7 @@ def get_records(self, collection, full=True, ids=None, newer=None, sorts the output: "newest" - orders by last-modified time, largest first "index" - orders by the sortindex, highest weight first + "oldest" - orders by last-modified time, oldest first """ params = kwargs.pop('params', {}) if full: @@ -209,7 +210,7 @@ def get_records(self, collection, full=True, ids=None, newer=None, params['limit'] = limit if offset is not None: params['offset'] = offset - if sort is not None and sort in ('newest', 'index'): + if sort is not None and sort in ('newest', 'index', 'oldest'): params['sort'] = sort return self._request('get', '/storage/%s' % collection.lower(), From d21c5e8a661c7249af32a6f9bab0153086efdc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Mon, 12 Oct 2015 14:54:53 +0200 Subject: [PATCH 2/2] Add a test. --- tests/test_client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index 2ee77ef..74c462d 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -334,6 +334,12 @@ def test_get_records_handles_sort_by_newest(self): 'get', '/storage/mycollection', params={'sort': 'newest', 'full': True}) + def test_get_records_handles_sort_by_oldest(self): + self.client.get_records('mycollection', sort='oldest') + self.client._request.assert_called_with( + 'get', '/storage/mycollection', + params={'sort': 'oldest', 'full': True}) + def test_get_records_handles_sort_by_index(self): self.client.get_records('mycollection', sort='index') self.client._request.assert_called_with(