Sonarfix: Reduce cognitive complexity
[vvp/validation-scripts.git] / ice_validator / tests / test_nova_servers_workload_context.py
index 4c2ec10..dc4c437 100644 (file)
@@ -43,7 +43,7 @@
 import pytest
 from tests import cached_yaml as yaml
 
-from .helpers import validates
+from .helpers import validates, get_param
 
 VERSION = "1.0.0"
 
@@ -89,16 +89,7 @@ def validate_metadata(metadata, parameters):
     Return error message string or None if no errors.
     """
     for value in metadata.values():
-        if isinstance(value, dict):
-            if "get_param" in value:
-                if value["get_param"] == "workload_context":
-                    wc = parameters.get("workload_context", {})
-                    if wc.get("type") == "string":
-                        break
-                    else:
-                        return (
-                            'must have parameter "workload_context"' ' of type "string"'
-                        )
-                    break
-    else:
-        return None
+        if get_param(value) == "workload_context" and parameters.get("workload_context", {}).get("type", "") != "string":
+            return 'must have parameter "workload_context" of type "string"'
+        else:
+            return None