X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FIoTDM%2Fcriotdm.py;h=680a42eca9da99d0fa4c822ba6d9f7435e55e0c2;hb=1c106006ffb33c1c60e2f8abe61e88a7bd95a7bd;hp=ad67a6376cd23aa5e77a643e71c2939ddac98416;hpb=e235045c2ad12d41416e2583609a0178c8bd9287;p=integration%2Ftest.git diff --git a/csit/libraries/IoTDM/criotdm.py b/csit/libraries/IoTDM/criotdm.py index ad67a6376c..680a42eca9 100644 --- a/csit/libraries/IoTDM/criotdm.py +++ b/csit/libraries/IoTDM/criotdm.py @@ -4,8 +4,7 @@ import ciotdm def connect_to_iotdm(host, user, password, prot="http"): """According to protocol, connect to iotdm.""" - return ciotdm.connect(host, base="InCSE1", auth=( - user, password), protocol=prot) + return ciotdm.connect(host, base="InCSE1", auth=(user, password), protocol=prot) def modify_headers_origin(connection, new_origin): @@ -20,11 +19,9 @@ def create_resource(connection, parent, restype, attribute=None): return connection.response -def create_resource_with_command(connection, parent, restype, - command, attribute=None): +def create_resource_with_command(connection, parent, restype, command, attribute=None): """According to command in the header, create the resource.""" - connection.create_with_command(parent, restype, - command, attribute) + connection.create_with_command(parent, restype, command, attribute) check_response(connection.response, "create") return connection.response @@ -32,9 +29,11 @@ def create_resource_with_command(connection, parent, restype, def create_subscription(connection, parent, ip, port): """Create subscription.""" uri = "http://%s:%d" % (ip, int(port)) - connection.create(parent, "subscription", { - "notificationURI": uri, - "notificationContentType": "wholeResource"}) + connection.create( + parent, + "subscription", + {"notificationURI": uri, "notificationContentType": "wholeResource"}, + ) check_response(connection.response, "create") return connection.response @@ -60,8 +59,7 @@ def update_resource(connection, resid, restype, attr): return connection.response -def update_resource_with_command(connection, resid, - restype, command, attr): +def update_resource_with_command(connection, resid, restype, command, attr): """According to command, update resource with resourceID.""" connection.update_with_command(resid, restype, command, attr) check_response(connection.response, "update") @@ -106,7 +104,7 @@ def name(response): """Return resourceName.""" resource_name = ciotdm.name(response) if resource_name is None: - raise AssertionError('Cannot find this resource') + raise AssertionError("Cannot find this resource") return resource_name @@ -167,22 +165,24 @@ def elapsed(response): def location(response): """Return response content-location.""" - return response.headers['Content-Location'] + return response.headers["Content-Location"] def kill_the_tree(host, cseid, username, password): """Delete the whole tree.""" - connection = ciotdm.connect(host, base=cseid, - auth=(username, password), protocol="http") + connection = ciotdm.connect( + host, base=cseid, auth=(username, password), protocol="http" + ) connection.kill() def check_response(response, operation): """Check whether the connection is none.""" if response is None: - raise AssertionError('Cannot %s this resource') % (operation) - elif hasattr(response, 'status_code'): + raise AssertionError("Cannot %s this resource") % (operation) + elif hasattr(response, "status_code"): if response.status_code < 200 or response.status_code > 299: raise AssertionError( - 'Cannot %s this resource [%d] : %s' % - (operation, response.status_code, response.text)) + "Cannot %s this resource [%d] : %s" + % (operation, response.status_code, response.text) + )