aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMamtha <mamtha.sabesan@in.ibm.com>2019-10-30 23:51:35 +0530
committerMamtha <mamtha.sabesan@in.ibm.com>2019-10-30 23:55:18 +0530
commite2b5191d127ab0e8c019112c2e75238d76a01897 (patch)
treece5e8c5fd8a527baf5d7dbd56cc3b8c469ed5ada
parentd87106650286493af38cecd423b58bdcead15db4 (diff)
Sonar fix for vvp 291 and 292
Issue-ID: VVP-291 Change-Id: I4d2eebbb9d4d96b17cc09a5de34e95e41cb9ec7d Signed-off-by: Mamtha <mamtha.sabesan@in.ibm.com>
-rw-r--r--ice_validator/tests/test_nova_servers_environment_context.py19
-rw-r--r--ice_validator/tests/test_nova_servers_vm_types.py9
2 files changed, 6 insertions, 22 deletions
diff --git a/ice_validator/tests/test_nova_servers_environment_context.py b/ice_validator/tests/test_nova_servers_environment_context.py
index 0da97f2..780733a 100644
--- a/ice_validator/tests/test_nova_servers_environment_context.py
+++ b/ice_validator/tests/test_nova_servers_environment_context.py
@@ -43,7 +43,8 @@
import pytest
from tests import cached_yaml as yaml
-from .helpers import validates
+from .helpers import validates, get_param
+
VERSION = "1.0.0"
@@ -89,17 +90,5 @@ 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"] == "environment_context":
- wc = parameters.get("environment_context", {})
- if wc.get("type") == "string":
- break
- else:
- return (
- 'must have parameter "environment_context"'
- ' of type "string"'
- )
- break
- else:
- return None
+ if get_param(value) == "environment_context" and parameters.get("environment_context", {}).get("type", "") != "string":
+ return 'must have parameter "environment_context" of type "string"'
diff --git a/ice_validator/tests/test_nova_servers_vm_types.py b/ice_validator/tests/test_nova_servers_vm_types.py
index d3d0dbb..36ada32 100644
--- a/ice_validator/tests/test_nova_servers_vm_types.py
+++ b/ice_validator/tests/test_nova_servers_vm_types.py
@@ -42,7 +42,7 @@ import re
from tests import cached_yaml as yaml
-from .helpers import validates
+from .helpers import validates, is_nova_server
from .utils.vm_types import get_vm_types_for_resource, get_vm_types
@@ -64,13 +64,8 @@ def test_vm_type_consistent_on_nova_servers(yaml_file):
invalid_nova_servers = []
for k, v in yml["resources"].items():
- if not isinstance(v, dict):
- continue
- if v.get("type") != "OS::Nova::Server":
+ if not is_nova_server(v):
continue
- if "properties" not in v:
- continue
-
vm_types = get_vm_types_for_resource(v)
if len(vm_types) != 1:
invalid_nova_servers.append(k)