Merge "Prevent error in _parse_resp when nullable list"
This commit is contained in:
commit
5aad8e753a
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
When receiving nullable list as a response body, tempest.lib
|
||||
rest_client module raised an exception without valid json
|
||||
deserialization. A new release fixes this bug.
|
@ -474,7 +474,7 @@ class RestClient(object):
|
||||
# Ensure there are not more than one top-level keys
|
||||
# NOTE(freerunner): Ensure, that JSON is not nullable to
|
||||
# to prevent StopIteration Exception
|
||||
if len(body.keys()) != 1:
|
||||
if not hasattr(body, "keys") or len(body.keys()) != 1:
|
||||
return body
|
||||
# Just return the "wrapped" element
|
||||
first_key, first_item = six.next(six.iteritems(body))
|
||||
|
@ -276,6 +276,11 @@ class TestRestClientParseRespJSON(BaseRestClientTestClass):
|
||||
body = self.rest_client._parse_resp(json.dumps(self.null_dict))
|
||||
self.assertEqual(self.null_dict, body)
|
||||
|
||||
def test_parse_empty_list(self):
|
||||
empty_list = []
|
||||
body = self.rest_client._parse_resp(json.dumps(empty_list))
|
||||
self.assertEqual(empty_list, body)
|
||||
|
||||
|
||||
class TestRestClientErrorCheckerJSON(base.TestCase):
|
||||
c_type = "application/json"
|
Loading…
x
Reference in New Issue
Block a user