aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzhilarasi <ezhrajam@in.ibm.com>2019-09-26 17:17:50 +0530
committerEzhilarasi R <ezhrajam@in.ibm.com>2019-10-01 13:52:49 +0000
commit800b9dc706ded01d69b3ffd2fbf8b816b4c0a6db (patch)
tree44f3a205b5bf225f1d23c19a75438d9d379baef7
parent1d319a416ba8f0cb764d86323f78318b0d3a8f4c (diff)
Sonarfix: Reduce cognitive complexity
Reduced cognitive complexity in validate_metadata method Change-Id: I195971985214f54a44c56a2e425825251a91c83b Issue-ID: VVP-294 Signed-off-by: Ezhilarasi <ezhrajam@in.ibm.com>
-rw-r--r--ice_validator/tests/test_nova_servers_workload_context.py19
1 files changed, 5 insertions, 14 deletions
diff --git a/ice_validator/tests/test_nova_servers_workload_context.py b/ice_validator/tests/test_nova_servers_workload_context.py
index 4c2ec10..dc4c437 100644
--- a/ice_validator/tests/test_nova_servers_workload_context.py
+++ b/ice_validator/tests/test_nova_servers_workload_context.py
@@ -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