change if bad to assert not bad, message
[vvp/validation-scripts.git] / ice_validator / tests / test_heat_pairs_provided.py
index 76aa276..149a547 100644 (file)
@@ -35,7 +35,6 @@
 #
 # ============LICENSE_END============================================
 #
 #
 # ============LICENSE_END============================================
 #
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 from os import path
 #
 
 from os import path
@@ -43,24 +42,54 @@ from os import path
 from .helpers import validates
 
 
 from .helpers import validates
 
 
-@validates('R-86285', 'R-38474', 'R-81725', 'R-53433', 'R-56438',
-           'R-74304', 'R-91342', 'R-94509', 'R-31141')
+@validates(
+    "R-86285",
+    "R-38474",
+    "R-81725",
+    "R-53433",
+    "R-56438",
+    "R-74304",
+    "R-91342",
+    "R-94509",
+    "R-31141",
+)
 def test_heat_pairs_provided(heat_templates, env_files, volume_templates):
 def test_heat_pairs_provided(heat_templates, env_files, volume_templates):
-    '''
+    """
     Check that every yaml file is submitted with
     an associated env file, and every env has an
     associated yaml file.
     Check that every yaml file is submitted with
     an associated env file, and every env has an
     associated yaml file.
-    '''
+    """
 
 
+    env_files_missing_template = []
     for filename in env_files:
         basename = path.splitext(filename)[0]
     for filename in env_files:
         basename = path.splitext(filename)[0]
-        assert basename + '.yaml' in heat_templates or \
-            basename + '.yml' in heat_templates or \
-            basename + '.yml' in volume_templates or \
-            basename + '.yaml' in volume_templates
+        if not (
+            basename + ".yaml" in heat_templates
+            or basename + ".yml" in heat_templates
+            or basename + ".yml" in volume_templates
+            or basename + ".yaml" in volume_templates
+        ):
+            env_files_missing_template.append(filename)
+
+    heat_template_missing_env = []
     for filename in heat_templates:
         basename = path.splitext(filename)[0]
     for filename in heat_templates:
         basename = path.splitext(filename)[0]
-        assert basename + '.env' in env_files
+        if not basename + ".env" in env_files:
+            heat_template_missing_env.append(filename)
+
     for filename in volume_templates:
         basename = path.splitext(filename)[0]
     for filename in volume_templates:
         basename = path.splitext(filename)[0]
-        assert basename + '.env' in env_files
+        if not basename + ".env" in env_files:
+            heat_template_missing_env.append(filename)
+
+    msg = (
+        "Mismatched template and environment file pairs detected. "
+        + "Environment files with no matching template: {} ".format(
+            env_files_missing_template
+        )
+        + "Heat templates with no matching environment file: {}".format(
+            heat_template_missing_env
+        )
+    )
+
+    assert not (env_files_missing_template or heat_template_missing_env), msg