aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEzhilarasi <ezhrajam@in.ibm.com>2019-09-27 22:50:12 +0530
committerEzhilarasi R <ezhrajam@in.ibm.com>2019-10-01 08:18:00 +0000
commit79a369f8312657f179ccd13431ab1b6842e77721 (patch)
treec2d754beba74ba6f6979487688754e069f27915b
parent1d319a416ba8f0cb764d86323f78318b0d3a8f4c (diff)
Sonarfix: Reduced cognitive compexity
Reduced cognitive compexity by replacing if conditions Change-Id: If198c2b82dd132c343bbe9db8cd3064750998785 Issue-ID: VVP-287 Signed-off-by: Ezhilarasi <ezhrajam@in.ibm.com>
-rw-r--r--ice_validator/tests/test_availability_zone.py31
1 files changed, 12 insertions, 19 deletions
diff --git a/ice_validator/tests/test_availability_zone.py b/ice_validator/tests/test_availability_zone.py
index aee6890..0cbb0d2 100644
--- a/ice_validator/tests/test_availability_zone.py
+++ b/ice_validator/tests/test_availability_zone.py
@@ -45,7 +45,7 @@ import pytest
from tests import cached_yaml as yaml
from tests.utils import nested_files
-from .helpers import validates
+from .helpers import validates, is_nova_server
VERSION = "1.1.0"
@@ -69,26 +69,19 @@ def test_availability_zone_naming(yaml_file):
invalid_availability_zones = set()
for k1, v1 in yml["resources"].items():
- if not isinstance(v1, dict):
- continue
- if "properties" not in v1:
- continue
- if "type" not in v1:
+ if not is_nova_server(v1):
continue
- if v1["type"] == "OS::Nova::Server":
- for k2, v2 in v1["properties"].items():
- if k2 != "availability_zone":
- continue
- if "str_replace" in v2:
- continue
- if "get_param" not in v2:
- invalid_availability_zones.add(k1)
- continue
- if not isinstance(v2["get_param"], str):
- continue
- if not re.match(r"availability_zone_\d+", v2["get_param"]):
- invalid_availability_zones.add(v2["get_param"])
+ for k2, v2 in v1["properties"].items():
+ if k2 != "availability_zone" or "str_replace" in v2:
+ continue
+ if "get_param" not in v2:
+ invalid_availability_zones.add(k1)
+ continue
+ if not isinstance(v2["get_param"], str):
+ continue
+ if not re.match(r"availability_zone_\d+", v2["get_param"]):
+ invalid_availability_zones.add(v2["get_param"])
assert not invalid_availability_zones, "invalid availability zones %s" % list(
invalid_availability_zones