diff options
author | Steven Wright <sw3588@att.com> | 2019-01-31 20:04:44 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-01-31 20:04:44 +0000 |
commit | ab01f96b1405bc037853847138a121581bb98f05 (patch) | |
tree | fd7929e29a090ca4b0eeb724e07094e9608ee51a | |
parent | 8540eb59f7e7f8ff2043a8eaf7edfc255a60874a (diff) | |
parent | d2347d7b9288f6bc433fee5e060c4b3d91597ac8 (diff) |
Merge "[VVP] Creating table for RST ingestion"
-rw-r--r-- | ice_validator/tests/conftest.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py index 807ac71..a2f4321 100644 --- a/ice_validator/tests/conftest.py +++ b/ice_validator/tests/conftest.py @@ -63,6 +63,8 @@ DEFAULT_OUTPUT_DIR = "{}/../output".format(__path__[0]) RESOLUTION_STEPS_FILE = "resolution_steps.json" HEAT_REQUIREMENTS_FILE = os.path.join(__path__[0], "..", "heat_requirements.json") +TEST_SCRIPT_SITE = "https://github.com/onap/vvp-validation-scripts/blob/master/ice_validator/tests/" +VNFRQTS_ID_URL = "https://docs.onap.org/en/latest/submodules/vnfrqts/requirements.git/docs/" REPORT_COLUMNS = [ ("Input File", "file"), @@ -1027,6 +1029,50 @@ def select_heat_requirements(reqs): return {k: v for k, v in reqs.items() if "Heat" in v["docname"]} +def build_rst_json(reqs): + """Takes requirements and returns list of only Heat requirements""" + data = json.loads(reqs) + for key, values in list(data.items()): + if "Heat" in (values["docname"]): + if "MUST" in (values["keyword"]): + if "none" in (values["validation_mode"]): + del data[key] + else: + """Creates links in RST format to requirements and test cases""" + if values["test_case"]: + val_list = re.findall(r'(?<=\.).*', values["test_case"]) + val = TEST_SCRIPT_SITE + val_list[0] + ".py" + rst_value = ("`" + val_list[0] + " <" + val + ">`_") + title = "`" + values["id"] + " <" + VNFRQTS_ID_URL + values["docname"].replace(" ", "%20") + ".html#" + values["id"] + ">`_" + data[key].update({'full_title': title, 'test_case': rst_value}) + else: + del data[key] + else: + del data[key] + else: + del data[key] + return data + + +def generate_rst_table(data): + """Generate a formatted csv to be used in RST""" + rst_path = os.path.join(__path__[0], "../output/rst.csv") + with open(rst_path, "w", newline="") as f: + out = csv.writer(f) + out.writerow( + ("Requirement ID", "Requirement", "Test Module", "Test Name"), + ) + for req_id, metadata in data.items(): + out.writerow( + ( + metadata["full_title"], + metadata["description"], + metadata["test_case"], + metadata["validated_by"], + ) + ) + + # noinspection PyUnusedLocal def pytest_report_collectionfinish(config, startdir, items): """Generates a simple traceability report to output/traceability.csv""" @@ -1046,6 +1092,8 @@ def pytest_report_collectionfinish(config, startdir, items): for req_id in item.function.requirement_ids: if req_id not in req_to_test: req_to_test[req_id].add(item) + if req_id in requirements: + reqs[req_id].update({'test_case': item.function.__module__, 'validated_by': item.function.__name__}) if req_id not in requirements: mapping_errors.add( (req_id, item.function.__module__, item.function.__name__) @@ -1107,3 +1155,5 @@ def pytest_report_collectionfinish(config, startdir, items): test_module, test_name) ) + + generate_rst_table(build_rst_json(json.dumps(reqs))) |