Skip to content

Commit 2dea8bb

Browse files
committed
Fix bug #11
Correct RestSession.get_items() to check for the existence of a JSON ‘items’ attribute by checking to see ‘if items is None’ instead of just checking for ‘if items’, which incorrectly raises the error when ‘items’ is present but is an empty array.
1 parent 20ed390 commit 2dea8bb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ciscosparkapi/restsession.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ def get_items(self, url, params=None, **kwargs):
144144
# objects contained within the top level 'items' array
145145
assert isinstance(json_page, dict)
146146
items = json_page.get(u'items')
147-
if items:
148-
for item in items:
149-
yield item
150-
else:
147+
if items is None:
151148
error_message = "'items' object not found in JSON data: " \
152149
"{!r}".format(json_page)
153150
raise ciscosparkapiException(error_message)
151+
else:
152+
for item in items:
153+
yield item
154154

155155
def post(self, url, json, **kwargs):
156156
# Process args

0 commit comments

Comments
 (0)