Reduced coginitive compexity from 16 to 15
[vvp/validation-scripts.git] / ice_validator / tests / helpers.py
index fefa8de..764be11 100644 (file)
@@ -393,7 +393,10 @@ def unzip(zip_path, target_dir):
     :param zip_path:    path to valid zip file
     :param target_dir:  directory to unzip zip_path
     """
-    check(zipfile.is_zipfile(zip_path), "{} is not a valid zipfile or does not exist".format(zip_path))
+    check(
+        zipfile.is_zipfile(zip_path),
+        "{} is not a valid zipfile or does not exist".format(zip_path),
+    )
     archive = zipfile.ZipFile(zip_path)
     if not os.path.exists(target_dir):
         os.makedirs(target_dir, exist_ok=True)
@@ -412,3 +415,11 @@ def remove(sequence, exclude, key=None):
     key_func = key if key else lambda x: x
     result = (s for s in sequence if key_func(s) not in exclude)
     return set(result) if isinstance(sequence, Set) else list(result)
+
+
+def is_nova_server(resource):
+    """
+    checks resource is a nova server
+    """
+    return isinstance(resource, dict) and "type" in resource and "properties" in resource and resource.get("type") == "OS::Nova::Server"
+