diff options
author | Moshe <moshehoa@amdocs.com> | 2018-06-20 10:23:28 +0300 |
---|---|---|
committer | Moshe <moshehoa@amdocs.com> | 2018-06-20 12:13:36 +0300 |
commit | c7c4cc227ed9447b4fdceeceece35384404bd7ec (patch) | |
tree | 5a7900dfa5ce66c1821e2ab0719741e9cccfb126 /vnftest/common/rest_client.py | |
parent | e65155cab8d6d74989f1dd0bd1a493e1c91a30d9 (diff) |
Add validation abilities to test cases
Change-Id: I76b28e6170d6e91836b195d58c0b882168c11a67
Issue-ID: VNFSDK-275
Signed-off-by: Moshe <moshehoa@amdocs.com>
Add unit tests
Issue-ID: VNFSDK-275
Change-Id: I34bc9a11e16e4092fdad3b4a1733c7219e624f5f
Signed-off-by: Moshe <moshehoa@amdocs.com>
add unit tests
Issue-ID: VNFSDK-275
Change-Id: Ib99c3521438b002e0d8aaff9870224673e34899f
Signed-off-by: Moshe <moshehoa@amdocs.com>
add unit tests
Issue-ID: VNFSDK-275
Change-Id: I1ac560dfb40df5f346b0db8f40b8c52a2fb6b350
Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'vnftest/common/rest_client.py')
-rw-r--r-- | vnftest/common/rest_client.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/vnftest/common/rest_client.py b/vnftest/common/rest_client.py index 23a108c..051f5dd 100644 --- a/vnftest/common/rest_client.py +++ b/vnftest/common/rest_client.py @@ -14,9 +14,17 @@ ############################################################################## import json + +import logging +import os import urllib2 import requests +from vnftest.common import utils + +logger = logging.getLogger(__name__) +os.putenv('PYTHONHTTPSVERIFY', "0") + def post(url, headers, data, logger): return call(url, 'POST', headers, data, logger) @@ -31,10 +39,15 @@ def call(url, method, headers, data, logger): f = urllib2.urlopen(req) return_code = f.code response_body = f.read() + headers = f.headers + content_type = headers.dict['content-type'] if 'content-type' in headers.dict else 'application/json' f.close() if len(str(response_body)) == 0: response_body = "{}" - response_body = json.loads(response_body) + if 'application/xml' in content_type: + response_body = utils.xml_to_dict(response_body) + else: + response_body = json.loads(response_body) result = {'return_code': return_code, 'body': response_body} return result |