[VVP] create new validation scripts
[vvp/validation-scripts.git] / ice_validator / tests / test_heat_template_structure.py
index 3bbca31..cc05df9 100644 (file)
@@ -37,7 +37,7 @@
 #
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
-
+from .helpers import validates
 import yaml
 
 
@@ -51,9 +51,10 @@ def test_heat_template_structure(yaml_file):
 
     with open(yaml_file) as fh:
         yml = yaml.load(fh)
-    assert any(map(lambda v: v in yml, key_values))
+    assert all([k in key_values for k in yml])
 
 
+@validates('R-27078', 'R-39402', 'R-35414')
 def test_heat_template_structure_contains_required_sections(yaml_file):
     '''
     Check that all heat templates have the required sections
@@ -63,7 +64,7 @@ def test_heat_template_structure_contains_required_sections(yaml_file):
 
     with open(yaml_file) as fh:
         yml = yaml.load(fh)
-    assert any(map(lambda v: v in yml, required_key_values))
+    assert all([k in yml for k in required_key_values])
 
 
 def test_heat_template_structure_sections_have_the_right_format(yaml_file):
@@ -95,3 +96,28 @@ def test_heat_template_structure_sections_have_the_right_format(yaml_file):
                     should_not_be_dict += 1
     assert (is_dict == should_be_dict and
             is_not_dict == should_not_be_dict)
+
+
+@validates('R-11441')
+def test_parameter_type(yaml_file):
+    types = [
+            'string',
+            'number',
+            'json',
+            'comma_delimited_list',
+            'boolean',
+            ]
+    with open(yaml_file) as fh:
+        yml = yaml.load(fh)
+    for key, param in yml.get('parameters', {}).items():
+        assert isinstance(param, dict), '%s parameter %s is not dict' % (
+                yaml_file,
+                key)
+        assert 'type' in param, '%s parameter %s has no "type"' % (
+                yaml_file,
+                key)
+        typ = param['type']
+        assert typ in types, '%s parameter %s has invalid type "%s"' % (
+                yaml_file,
+                key,
+                typ)