Skip to content

Commit be045e8

Browse files
committed
Merge pull request Clever#31 from eosrei/15/no-results
Return empty list when there are no results to fix Clever#15 w/test
2 parents 0b22961 + f1e4389 commit be045e8

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

test/test_clever.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ def test_keys_and_values_methods(self):
137137
self.assertEqual(clever_object.keys(), set())
138138
self.assertEqual(clever_object.values(), set())
139139

140+
def test_empty_list_on_no_data(self):
141+
district = clever.District.all(where=json.dumps({'name': 'asdf'}))
142+
self.assertEqual(district, [])
143+
140144
class AuthenticationErrorTest(CleverTestCase):
141145

142146
def test_invalid_credentials(self):

0 commit comments

Comments
 (0)