Skip to content

Commit f1e4389

Browse files
committed
Return empty list when there are no results to fix Clever#15 w/test
1 parent 41c16a0 commit f1e4389

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

clever/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,9 @@ def iter(cls, auth=None, **params):
721721

722722
while url:
723723
response, auth = requestor.request('get', url, params)
724+
# Generate nothing when there is no data.
725+
if len(response['data']) == 0:
726+
break
724727
for datum in convert_to_clever_object(cls, response, auth):
725728
yield datum
726729
url = get_link(response, 'next')

test/test_clever.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ def test_keys_and_values_methods(self):
112112
self.assertEqual(clever_object.keys(), set())
113113
self.assertEqual(clever_object.values(), set())
114114

115+
def test_empty_list_on_no_data(self):
116+
district = clever.District.all(where=json.dumps({'name': 'asdf'}))
117+
self.assertEqual(district, [])
118+
115119
class AuthenticationErrorTest(CleverTestCase):
116120

117121
def test_invalid_credentials(self):

0 commit comments

Comments
 (0)