Merge "Reduce cognitive complexity"
authorSteven Wright <sw3588@att.com>
Tue, 1 Oct 2019 14:26:09 +0000 (14:26 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 1 Oct 2019 14:26:09 +0000 (14:26 +0000)
ice_validator/tests/test_network_format.py
ice_validator/tests/utils/vm_types.py
ice_validator/version.py
pom.xml
releases/5.0.0-container.yaml [new file with mode: 0644]

index f146f75..e360795 100644 (file)
@@ -70,9 +70,7 @@ def test_network_resource_id_format(yaml_file):
 
     invalid_networks = []
     for k, v in yml["resources"].items():
-        if not isinstance(v, dict):
-            continue
-        if "properties" not in v:
+        if not has_properties(v):
             continue
         if property_uses_get_resource(v, "network"):
             continue
@@ -106,23 +104,15 @@ def test_network_has_subnet(yaml_file):
     networks = []
 
     for k, v in yml["resources"].items():
-        if not isinstance(v, dict):
-            continue
-        if "properties" not in v:
+        if not has_properties(v) or v.get("type") not in ["OS::Neutron::Net"]:
             continue
         # need to check if contrail networks also require subnet
         # and it is defined the same as neutron networks
         # if v.get("type") not in NETWORK_RESOURCE_TYPES:
-        if v.get("type") not in ["OS::Neutron::Net"]:
-            continue
         networks.append(k)
 
     for k, v in yml["resources"].items():
-        if not isinstance(v, dict):
-            continue
-        if "properties" not in v:
-            continue
-        if v.get("type") != "OS::Neutron::Subnet":
+        if not has_properties(v) and v.get("type") != "OS::Neutron::Subnet":
             continue
         network_prop = v.get("properties", {}).get("network", {}).get("get_resource")
 
@@ -136,3 +126,10 @@ def test_network_has_subnet(yaml_file):
             x += 1
 
     assert not networks, "Networks detected without subnet {}".format(networks)
+
+
+def has_properties(resource):
+    """
+    checks resource is a Neutron Subnet
+    """
+    return isinstance(resource, dict) and "properties" in resource
index ae6d7ff..7570581 100644 (file)
@@ -50,8 +50,6 @@ def get_vm_types_for_resource(resource):
     - If more than one vm_type is detected all vm_types will
     be returned
     """
-    if not isinstance(resource, dict):
-        return set()
     if not is_nova_server(resource):
         return set()
 
@@ -83,11 +81,7 @@ def get_vm_types_for_resource(resource):
 
 def is_nova_server(resource):
 
-    return (
-        "type" in resource
-        and "properties" in resource
-        and resource.get("type") == "OS::Nova::Server"
-    )
+    return isinstance(resource, dict) and "type" in resource and "properties" in resource and resource.get("type") == "OS::Nova::Server"
 
 
 def get_vm_type_for_nova_server(resource):
index f628f8e..1ef4a2c 100644 (file)
@@ -37,6 +37,6 @@
 #
 #
 
-VERSION = "5.0.0"
+VERSION = "5.0.1"
 BRANCH = "master"
 RELEASE = "elalto"
diff --git a/pom.xml b/pom.xml
index 8c1fab1..3f867ef 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
   <groupId>org.onap.vvp.validation-scripts</groupId>
   <artifactId>validation-scripts</artifactId>
   <packaging>pom</packaging>
-  <version>5.0.0</version>
+  <version>5.0.1</version>
   <name>vvp-validation-scripts</name>
 
   <properties>
diff --git a/releases/5.0.0-container.yaml b/releases/5.0.0-container.yaml
new file mode 100644 (file)
index 0000000..f74e8c6
--- /dev/null
@@ -0,0 +1,8 @@
+distribution_type: 'container'
+container_release_tag: '5.0.0'
+project: 'vvp'
+log_dir: 'vvp-validation-scripts-master-docker-java-daily/259/'
+ref: f5190cf61981eff1eb59157d4d2f8bd06acb3570
+containers:
+    - name: 'vvp/validation-scripts'
+      version: '5.0.0-20190925T142421Z'