Skip to content
Snippets Groups Projects
Commit adfe87e0 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-142: only interpret/compare response content when statuscode is succesfull

parent 374d66dc
No related branches found
No related tags found
2 merge requests!98Resolve TMSS-142 and TMSS-141,!97Resolve TMSS-138
......@@ -65,7 +65,11 @@ def _call_API_and_assert_expected_response(test_instance, url, call, data, expec
if response.status_code != expected_code:
print("!!! Unexpected: [%s] - %s %s: %s" % (test_instance.id(), call, url, response.content.decode('utf-8').strip()))
test_instance.assertEqual(response.status_code, expected_code)
r_dict = json.loads(response.content.decode('utf-8'))
content = response.content.decode('utf-8')
if response.status_code in range(200, 100):
r_dict = json.loads(content)
for key, value in expected_content.items():
if key not in r_dict.keys():
print('!!! Missing key: %s in %s' % (key, r_dict.keys()))
......@@ -76,6 +80,12 @@ def _call_API_and_assert_expected_response(test_instance, url, call, data, expec
test_instance.assertEqual(value, r_dict[key])
return r_dict
try:
return json.loads(content)
except:
return content
def PUT_and_assert_expected_response(test_instance, url, data, expected_code, expected_content):
"""
PUT data on url and assert the expected code is returned and the expected content is in the response content
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment