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

Commit 19104ec

Browse files
authored
Merge pull request #315 from cloudant/297-changes-since-option
297 changes feed since option
2 parents bcafb0d + 9b5e532 commit 19104ec

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
2.6.0 (Unreleased)
22
==================
33
- [FIXED] Fixed client construction in ``cloudant_bluemix`` context manager.
4+
- [FIXED] Fixed validation for feed options to accept zero as a valid value.
45

56
2.5.0 (2017-07-06)
67
==================

src/cloudant/feed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _validate(self, key, val, arg_types):
116116
if (not isinstance(val, arg_types[key]) or
117117
(isinstance(val, bool) and int in arg_types[key])):
118118
raise CloudantArgumentError(117, key, arg_types[key])
119-
if isinstance(val, int) and val <= 0 and not isinstance(val, bool):
119+
if isinstance(val, int) and val < 0 and not isinstance(val, bool):
120120
raise CloudantArgumentError(118, key, val)
121121
if key == 'feed':
122122
valid_vals = ('continuous', 'normal', 'longpoll')

tests/unit/changes_tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,20 @@ def test_get_feed_using_since_now(self):
353353
expected = set(['julia003', 'julia004', 'julia005'])
354354
self.assertSetEqual(set([x['id'] for x in changes]), expected)
355355

356+
def test_get_feed_using_since_zero(self):
357+
"""
358+
Test getting content back for a feed using since set to zero
359+
"""
360+
self.populate_db_with_documents(3)
361+
feed = Feed(self.db, since=0)
362+
changes = list()
363+
for change in feed:
364+
self.assertSetEqual(set(change.keys()), {'seq', 'changes', 'id'})
365+
changes.append(change)
366+
expected = set(['julia{0:03d}'.format(i) for i in range(3)])
367+
self.assertSetEqual(set([x['id'] for x in changes]), expected)
368+
self.assertTrue(str(feed.last_seq).startswith('3'))
369+
356370
def test_get_feed_using_timeout(self):
357371
"""
358372
Test getting content back for a feed using timeout

0 commit comments

Comments
 (0)