Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #315 from cloudant/297-changes-since-option
Browse files Browse the repository at this point in the history
297 changes feed since option
  • Loading branch information
emlaver authored Aug 8, 2017
2 parents bcafb0d + 9b5e532 commit 19104ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2.6.0 (Unreleased)
==================
- [FIXED] Fixed client construction in ``cloudant_bluemix`` context manager.
- [FIXED] Fixed validation for feed options to accept zero as a valid value.

2.5.0 (2017-07-06)
==================
Expand Down
2 changes: 1 addition & 1 deletion src/cloudant/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _validate(self, key, val, arg_types):
if (not isinstance(val, arg_types[key]) or
(isinstance(val, bool) and int in arg_types[key])):
raise CloudantArgumentError(117, key, arg_types[key])
if isinstance(val, int) and val <= 0 and not isinstance(val, bool):
if isinstance(val, int) and val < 0 and not isinstance(val, bool):
raise CloudantArgumentError(118, key, val)
if key == 'feed':
valid_vals = ('continuous', 'normal', 'longpoll')
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/changes_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,20 @@ def test_get_feed_using_since_now(self):
expected = set(['julia003', 'julia004', 'julia005'])
self.assertSetEqual(set([x['id'] for x in changes]), expected)

def test_get_feed_using_since_zero(self):
"""
Test getting content back for a feed using since set to zero
"""
self.populate_db_with_documents(3)
feed = Feed(self.db, since=0)
changes = list()
for change in feed:
self.assertSetEqual(set(change.keys()), {'seq', 'changes', 'id'})
changes.append(change)
expected = set(['julia{0:03d}'.format(i) for i in range(3)])
self.assertSetEqual(set([x['id'] for x in changes]), expected)
self.assertTrue(str(feed.last_seq).startswith('3'))

def test_get_feed_using_timeout(self):
"""
Test getting content back for a feed using timeout
Expand Down

0 comments on commit 19104ec

Please sign in to comment.