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

Commit 38037b2

Browse files
committed
Fix _all_docs call where keys is an empty list
1 parent 41fc62d commit 38037b2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/cloudant/_common_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ def get_docs(r_session, url, encoder=None, headers=None, **params):
237237
"""
238238
keys_list = params.pop('keys', None)
239239
keys = None
240-
if keys_list:
240+
if keys_list is not None:
241241
keys = json.dumps({'keys': keys_list}, cls=encoder)
242242
f_params = python_to_couch(params)
243243
resp = None
244-
if keys:
244+
if keys is not None:
245245
# If we're using POST we are sending JSON so add the header
246246
if headers is None:
247247
headers = {}

tests/unit/database_tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,15 @@ def test_all_docs_post(self):
432432
keys_returned = [row['key'] for row in rows]
433433
self.assertTrue(all(x in keys_returned for x in keys_list))
434434

435+
def test_all_docs_post_empty_key_list(self):
436+
"""
437+
Test the all_docs POST request functionality using empty keys param
438+
"""
439+
self.populate_db_with_documents()
440+
# Request all_docs using an empty key list
441+
rows = self.db.all_docs(keys=[]).get('rows')
442+
self.assertEqual(len(rows), 0)
443+
435444
def test_all_docs_post_multiple_params(self):
436445
"""
437446
Test the all_docs POST request functionality using keys and other params

0 commit comments

Comments
 (0)