Auto-generated patch by python-black
[integration/test.git] / csit / libraries / IoTDM / criotdm.py
index ad67a6376cd23aa5e77a643e71c2939ddac98416..680a42eca9da99d0fa4c822ba6d9f7435e55e0c2 100644 (file)
@@ -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)
+            )