From be181843f2517de647f9dc1b9188b69186051aa6 Mon Sep 17 00:00:00 2001 From: "Lovett, Trevor" Date: Thu, 19 Sep 2019 16:37:29 -0500 Subject: [PATCH] [VVP] Removed additional f-string for build-upload issue Also made heat req't json and req't mapping optional in checks.py Change-Id: I38367e768de704cca3727bccb8f8bcdb04f9b193 Issue-ID: VVP-311 Signed-off-by: Lovett, Trevor --- checks.py | 23 ++++++++++++----------- ice_validator/preload/environment.py | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/checks.py b/checks.py index 4e5fb13..9f8740a 100644 --- a/checks.py +++ b/checks.py @@ -82,7 +82,7 @@ class Traceability: """ testable_mappings = [m for m in self.mappings if m[self.IS_TESTABLE] == "True"] return [ - f"Missing test for {m[self.REQ_ID]}" + f"WARN: Missing test for {m[self.REQ_ID]}" for m in testable_mappings if not m[self.TEST_NAME] ] @@ -137,22 +137,20 @@ def check_requirements_up_to_date(): """ Checks if the requirements file packaged with VVP has meaningful differences to the requirements file published from VNFRQTS. - :return: list of errors found """ - msg = ["heat_requirements.json is out-of-date. Run update_reqs.py to update."] + msg = "WARN: heat_requirements.json is out-of-date. Run update_reqs.py to update." latest_needs = json.load(get_requirements()) with open(CURRENT_NEEDS_PATH, "r") as f: current_needs = json.load(f) latest_reqs = select_items(in_scope, current_version(latest_needs)) current_reqs = select_items(in_scope, current_version(current_needs)) if set(latest_reqs.keys()) != set(current_reqs.keys()): - return msg - if not all( + print(msg) + elif not all( latest["description"] == current_reqs[r_id]["description"] for r_id, latest in latest_reqs.items() ): - return msg - return None + print(msg) def check_app_tests_pass(): @@ -173,7 +171,7 @@ def check_self_test_pass(): def check_testable_requirements_are_mapped(): tracing = Traceability() - return tracing.unmapped_requirement_errors() + print("\n".join(tracing.unmapped_requirement_errors())) def check_non_testable_requirements_are_not_mapped(): @@ -199,14 +197,15 @@ def check_bandit_passes(): stderr=subprocess.PIPE, # nosec ) # nosec msgs = result.stdout.split("\n") if result.returncode != 0 else [] - return ["bandit errors detected:"] + [f" {e}" for e in msgs] if msgs else [] + return ( + ["bandit errors detected:"] + [" {}".format(e) for e in msgs] if msgs else [] + ) if __name__ == "__main__": + checks = [ check_self_test_pass, - check_requirements_up_to_date, - check_testable_requirements_are_mapped, check_non_testable_requirements_are_not_mapped, check_flake8_passes, check_bandit_passes, @@ -214,4 +213,6 @@ if __name__ == "__main__": results = [check() for check in checks] errors = "\n".join("\n".join(msg) for msg in results if msg) print(errors or "Everything looks good!") + check_requirements_up_to_date() + check_testable_requirements_are_mapped() sys.exit(1 if errors else 0) diff --git a/ice_validator/preload/environment.py b/ice_validator/preload/environment.py index 4851fcb..083be9b 100644 --- a/ice_validator/preload/environment.py +++ b/ice_validator/preload/environment.py @@ -225,7 +225,7 @@ class PreloadEnvironment: return [e for e in all_envs if e.is_leaf] def get_module(self, name): - name = name if name.lower().endswith(".env") else f"{name}.env".lower() + name = name if name.lower().endswith(".env") else "{}.env".format(name).lower() if name not in self.module_names: return {} result = {} -- 2.16.6