Skip to content

Commit

Permalink
Fix bug #11
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmlccie committed Oct 4, 2016
1 parent 20ed390 commit 2dea8bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ciscosparkapi/restsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def get_items(self, url, params=None, **kwargs):
# objects contained within the top level 'items' array
assert isinstance(json_page, dict)
items = json_page.get(u'items')
if items:
for item in items:
yield item
else:
if items is None:
error_message = "'items' object not found in JSON data: " \
"{!r}".format(json_page)
raise ciscosparkapiException(error_message)
else:
for item in items:
yield item

def post(self, url, json, **kwargs):
# Process args
Expand Down

0 comments on commit 2dea8bb

Please sign in to comment.