X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ice_validator%2Ftests%2Ftest_servers_metadata_use_get_param.py;h=ab745c8a0ab1c04c089e5c48b628af665439a6d0;hb=8540eb59f7e7f8ff2043a8eaf7edfc255a60874a;hp=a5355442f5802dda10b7c2e113eff2c8a66b36f7;hpb=cc21b8b08b6dbcec577bfb26ff397ac899da8002;p=vvp%2Fvalidation-scripts.git diff --git a/ice_validator/tests/test_servers_metadata_use_get_param.py b/ice_validator/tests/test_servers_metadata_use_get_param.py index a535544..ab745c8 100644 --- a/ice_validator/tests/test_servers_metadata_use_get_param.py +++ b/ice_validator/tests/test_servers_metadata_use_get_param.py @@ -6,7 +6,7 @@ # =================================================================== # # Unless otherwise specified, all software contained herein is licensed -# under the Apache License, Version 2.0 (the “License”); +# under the Apache License, Version 2.0 (the "License"); # you may not use this software except in compliance with the License. # You may obtain a copy of the License at # @@ -21,7 +21,7 @@ # # # Unless otherwise specified, all documentation contained herein is licensed -# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); # you may not use this documentation except in compliance with the License. # You may obtain a copy of the License at # @@ -35,19 +35,19 @@ # # ============LICENSE_END============================================ # -# ECOMP is a trademark and service mark of AT&T Intellectual Property. # -import yaml import pytest +from tests import cached_yaml as yaml +from .helpers import validates -def test_servers_metadata_use_get_param(yaml_file): - ''' + +def check_servers_metadata_use_get_param(yaml_file, md): + """ Check all defined nova server instances include metadata via the get_param function - ''' - required_metadata = ["vnf_id", "vf_module_id"] + """ with open(yaml_file) as fh: yml = yaml.load(fh) @@ -64,11 +64,44 @@ def test_servers_metadata_use_get_param(yaml_file): if v1["type"] == "OS::Nova::Server": try: for k2, v2 in v1["properties"]["metadata"].items(): - if (k2 in required_metadata and not - v2["get_param"] in required_metadata): - invalid_nova_servers.append(k1) + if k2 == md: + if isinstance(v2, dict): + metadata = v2.get("get_param") + if not metadata: + invalid_nova_servers.append( + {"server": k1, "metadata": k2} + ) + else: + invalid_nova_servers.append({"server": k1, "metadata": k2}) except Exception as e: print(e) invalid_nova_servers.append(k1) - assert not set(invalid_nova_servers) + assert ( + not invalid_nova_servers + ), "OS::Nova::Server metadata MUST use get_param {}".format(invalid_nova_servers) + + +@validates("R-37437") +def test_servers_vnf_id_metadata_use_get_param(yaml_file): + check_servers_metadata_use_get_param(yaml_file, "vnf_id") + + +@validates("R-71493") +def test_servers_vf_module_id_metadata_use_get_param(yaml_file): + check_servers_metadata_use_get_param(yaml_file, "vf_module_id") + + +@validates("R-72483") +def test_servers_vnf_name_metadata_use_get_param(yaml_file): + check_servers_metadata_use_get_param(yaml_file, "vnf_name") + + +@validates("R-68023") +def test_servers_vf_module_name_metadata_use_get_param(yaml_file): + check_servers_metadata_use_get_param(yaml_file, "vf_module_name") + + +@validates("R-50816") +def test_servers_vf_module_index_metadata_use_get_param(yaml_file): + check_servers_metadata_use_get_param(yaml_file, "vf_module_index")