From daac9947156697f0f4ad6128e8ddcc3dcc7a204b Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Mon, 18 Nov 2024 18:56:46 +0000 Subject: [PATCH] Update GER to include all original content and have section numbers --- .../reports/globally_expanded/generate.py | 91 +++++++++++++++---- .../uss_availability_synchronization.md | 4 +- 2 files changed, 76 insertions(+), 19 deletions(-) diff --git a/monitoring/uss_qualifier/reports/globally_expanded/generate.py b/monitoring/uss_qualifier/reports/globally_expanded/generate.py index d71c975754..161698eecb 100644 --- a/monitoring/uss_qualifier/reports/globally_expanded/generate.py +++ b/monitoring/uss_qualifier/reports/globally_expanded/generate.py @@ -59,13 +59,15 @@ def generate_globally_expanded_report( ### Setup -* Test run information -* Resource pool +2. Test run information +3. Resource pool ### Test scenarios """ ) - + "\n".join(f"* {section.title}" for section in sections) + + "\n".join( + f"{str(s + 4)}. {section.title}" for s, section in enumerate(sections) + ) ) + "\n\n" ) @@ -165,6 +167,9 @@ def describe_pool_resource(k: str, v: dict) -> str: ger += "\n\n".join(f"## {section.title}\n\n{section.body}" for section in sections) + gerdoc = gfm.parse(ger) + _add_section_numbers(gerdoc.children[1:]) + os.makedirs(output_path, exist_ok=True) with open(os.path.join(output_path, "report.html"), "w") as f: f.write("\n") @@ -176,7 +181,7 @@ def describe_pool_resource(k: str, v: dict) -> str: ) as style: f.write(style.read()) f.write("\n") - f.write(gfm.render(gfm.parse(ger))) + f.write(gfm.render(gerdoc)) f.write("\n") f.write("\n") @@ -210,7 +215,7 @@ def _generate_scenario_section(scenario: TestedScenario) -> _Section: renderer = MarkdownRenderer() return _Section( - title=f"[{scenario.scenario_index}] {scenario.name}", + title=f"[S{scenario.scenario_index}] {scenario.name}", body=renderer.render_children(doc), ) @@ -282,13 +287,16 @@ def add_resource_origin(): if current_resource is None: return if current_resource not in scenario.resource_origins: - # This resource wasn't provided for this scenario instance; remove resource definition - doc.children = doc.children[0:current_resource_i0] + doc.children[c:] - c = current_resource_i0 + # This resource wasn't provided for this scenario instance + note = marko.parse( + """∅ _This resource was not applicable to this test run and was therefore not provided._\n\n""" + ) + doc.children = doc.children[0:c] + note.children + doc.children[c:] + c += len(note.children) return # Insert resource origin information origin = marko.parse( - f"\n\nProvided by {scenario.resource_origins[current_resource]}.\n" + f"\n\n✅ Provided by {scenario.resource_origins[current_resource]}.\n" ) doc.children = doc.children[0:c] + origin.children + doc.children[c:] c += len(origin.children) @@ -364,9 +372,16 @@ def add_context_to_case(): else: c += _add_context_to_case(doc, test_case, test_case_i0, c) else: - # This test case wasn't executed this test run; remove it - doc.children = doc.children[0:test_case_i0] + doc.children[c:] - c = test_case_i0 + # This test case wasn't executed this test run + note = marko.parse( + """∅ _This test case was not applicable to this test run and is therefore not statused._\n\n""" + ) + doc.children = ( + doc.children[0 : test_case_i0 + 1] + + note.children + + doc.children[test_case_i0 + 1 :] + ) + c += len(note.children) test_case = None test_case_i0 = None test_case_level = None @@ -428,9 +443,16 @@ def add_context_to_step(): if test_step is not None: dc = _add_context_to_step(doc, test_step, test_step_i0, c) else: - # This test step wasn't executed this test run; remove it - dc = test_step_i0 - c - doc.children = doc.children[0:test_step_i0] + doc.children[c:] + # This test step wasn't executed this test run + note = marko.parse( + """∅ _This test step was not applicable to this test run and is therefore not statused._\n\n""" + ) + dc = len(note.children) + doc.children = ( + doc.children[0 : test_step_i0 + 1] + + note.children + + doc.children[test_step_i0 + 1 :] + ) c += dc i1 += dc added += dc @@ -476,7 +498,6 @@ def _add_context_to_step( def add_context_to_check(): nonlocal c, i1, added, test_check_name, test_check_i0, test_check_level - # TODO: Remove checks which were not actually performed in this test run if test_check_name is not None: dc = _add_context_to_check(doc, step, test_check_name, test_check_i0, c) c += dc @@ -530,7 +551,12 @@ def _add_context_to_check( check_text.append( f"❌ {', '.join(event.failed_check.participants)} ({event.failed_check.timestamp})" ) - additions = marko.parse("\n\n".join(check_text)) + if len(check_text) > 1: + additions = marko.parse("\n\n".join(check_text)) + else: + additions = marko.parse( + """∅ _This check was not applicable to this test run and is therefore not statused._\n\n""" + ) doc.children = doc.children[0:i1] + additions.children + doc.children[i1:] return len(additions.children) @@ -554,3 +580,34 @@ def _update_links(element: marko.element.Element, origin_filename: str) -> None: for child in element.children: if isinstance(child, marko.element.Element): _update_links(child, origin_filename) + + +def _add_section_numbers(elements: Sequence[marko.element.Element]) -> None: + heading_level = 2 + levels = [0] + prev_heading = None + for i, element in enumerate(elements): + if isinstance(element, marko.block.Heading): + if element.level < heading_level: + levels = levels[0 : element.level - heading_level] + heading_level = element.level + levels[-1] += 1 + elif element.level == heading_level: + levels[-1] += 1 + elif element.level == heading_level + 1: + levels.append(1) + heading_level += 1 + else: + raise ValueError( + f"Encountered a level {element.level} heading ({text_of(element)}) at element {i} following a level {heading_level} heading ({prev_heading}); expected heading levels to increase by 1 level at a time" + ) + prev_heading = text_of(element) + section_number = ".".join(str(level) for level in levels) + ". " + if isinstance(element.children[0], marko.block.inline.RawText): + element.children[0].children = ( + section_number + element.children[0].children + ) + else: + element.children = [ + marko.block.inline.RawText(section_number) + ] + element.children diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss/synchronization/uss_availability_synchronization.md b/monitoring/uss_qualifier/scenarios/astm/utm/dss/synchronization/uss_availability_synchronization.md index 1abf99aff9..ed36df99e7 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss/synchronization/uss_availability_synchronization.md +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss/synchronization/uss_availability_synchronization.md @@ -102,12 +102,12 @@ it is in violation of the OpenAPI spec referenced by **[astm.f3548.v21.DSS0100,1 ## Cleanup -#### ⚠️ USS Availability can be requested check +### ⚠️ USS Availability can be requested check If, when queried for the availability of a USS using valid credentials, the DSS does not return a valid 200 response, it is in violation of the OpenAPI spec referenced by **[astm.f3548.v21.DSS0100,1](../../../../../requirements/astm/f3548/v21.md)**. -#### ⚠️ USS Availability can be set to Unknown check +### ⚠️ USS Availability can be set to Unknown check A valid request to set the availability of a USS to `Unknown` should be accepted by the DSS, otherwise it is failing to implement the OpenAPI spec referenced by **[astm.f3548.v21.DSS0100,1](../../../../../requirements/astm/f3548/v21.md)**.