diff options
author | Steven Wright <sw3588@att.com> | 2019-10-01 14:26:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-10-01 14:26:59 +0000 |
commit | f26cfe2f901be46fe1b016a21f3cc9d717b622b7 (patch) | |
tree | 1f677f6e9039079504792e2f7528bedfc56fe8bd /ice_validator/tests | |
parent | 4547da0cb865c4f40f82f9ba1769d508c8b512c0 (diff) | |
parent | 79a369f8312657f179ccd13431ab1b6842e77721 (diff) |
Merge "Sonarfix: Reduced cognitive compexity"
Diffstat (limited to 'ice_validator/tests')
-rw-r--r-- | ice_validator/tests/test_availability_zone.py | 31 |
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 |