Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
Merge pull request #18 from mozilla-services/47-oldest-sort
Browse files Browse the repository at this point in the history
Allow order by oldest.
  • Loading branch information
almet committed Oct 12, 2015
2 parents 7250955 + d21c5e8 commit 741a5d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion syncclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 741a5d2

Please sign in to comment.