Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
830 changes: 0 additions & 830 deletions .basedpyright/baseline.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from monitoring.uss_qualifier.action_generators.definitions import GeneratorTypeName
from monitoring.uss_qualifier.scenarios.definitions import TestScenarioTypeName
from monitoring.uss_qualifier.suites.definitions import (
ActionType,
TestSuiteDefinition,
TestSuiteTypeName,
)
Expand Down Expand Up @@ -34,9 +33,3 @@ class PotentialGeneratedAction(ImplicitDict):
test_scenario: Optional[PotentialTestScenarioAction]
test_suite: Optional[PotentialTestSuiteAction]
action_generator: Optional[PotentialActionGeneratorAction]

def get_action_type(self) -> ActionType:
matches = [v for v in ActionType if v in self and self[v]]
if len(matches) != 1:
raise ActionType.build_invalid_action_declaration()
return ActionType(matches[0])
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
PotentialTestSuiteAction,
)
from monitoring.uss_qualifier.suites.definitions import (
ActionType,
TestSuiteActionDeclaration,
)

Expand All @@ -36,16 +35,15 @@ def list_potential_actions_for_action_generator_definition(
def list_potential_actions_for_action_declaration(
declaration: TestSuiteActionDeclaration,
) -> list[PotentialGeneratedAction]:
action_type = declaration.get_action_type()
if action_type == ActionType.TestScenario:
if "test_scenario" in declaration and declaration.test_scenario:
return [
PotentialGeneratedAction(
test_scenario=PotentialTestScenarioAction(
scenario_type=declaration.test_scenario.scenario_type
)
)
]
elif action_type == ActionType.TestSuite:
elif "test_suite" in declaration and declaration.test_suite:
if "suite_type" in declaration.test_suite and declaration.test_suite.suite_type:
return [
PotentialGeneratedAction(
Expand All @@ -65,7 +63,7 @@ def list_potential_actions_for_action_declaration(
)
)
]
elif action_type == ActionType.ActionGenerator:
elif "action_generator" in declaration and declaration.action_generator:
return [
PotentialGeneratedAction(
action_generator=PotentialActionGeneratorAction(
Expand All @@ -74,4 +72,4 @@ def list_potential_actions_for_action_declaration(
)
]
else:
raise NotImplementedError(f"Action type {action_type} is not supported")
raise declaration.invalid_type_error
59 changes: 30 additions & 29 deletions monitoring/uss_qualifier/reports/globally_expanded/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
from monitoring.uss_qualifier.reports.sequence_view.summary_types import (
ActionNode,
ActionNodeType,
EpochType,
EventType,
Indexer,
TestedCase,
TestedScenario,
Expand Down Expand Up @@ -110,6 +108,7 @@ def generate_globally_expanded_report(

"""

assert report.configuration.v1 and report.configuration.v1.test_run
resource_pool = make_resources_config(report.configuration.v1.test_run)

def indented_ul(value) -> list[str]:
Expand Down Expand Up @@ -184,6 +183,7 @@ def describe_pool_resource(k: str, v: dict) -> str:

def _generate_sections(node: ActionNode) -> Iterator[_Section]:
if node.node_type == ActionNodeType.Scenario:
assert node.scenario
yield _generate_scenario_section(node.scenario)
elif node.node_type == ActionNodeType.SkippedAction:
yield _generate_skipped_scenario_section(node)
Expand All @@ -195,7 +195,7 @@ def _generate_sections(node: ActionNode) -> Iterator[_Section]:
def _generate_skipped_scenario_section(node: ActionNode) -> _Section:
return _Section(
title=f"[skipped] {node.name}",
body=f"This instance of this test scenario was skipped in this test run because: {node.skipped_action.reason}",
body=f"This instance of this test scenario was skipped in this test run because: {node.skipped_action.reason if node.skipped_action else '?'}",
)


Expand Down Expand Up @@ -237,15 +237,15 @@ def _indent_headings(elements: Sequence[marko.element.Element], levels: int) ->
for element in elements:
if isinstance(element, marko.block.Heading):
element.level = min(element.level + levels, 6)
if hasattr(element, "children") and element.children:
_indent_headings(element.children, levels)
if hasattr(element, "children") and element.children: # pyright: ignore[reportAttributeAccessIssue]
_indent_headings(element.children, levels) # pyright: ignore[reportAttributeAccessIssue]


def _inflate_fragments(parent: marko.element.Element, origin_filename: str) -> None:
if hasattr(parent, "children") and parent.children:
if hasattr(parent, "children") and parent.children: # pyright: ignore[reportAttributeAccessIssue]
c = 0
while c < len(parent.children):
child = parent.children[c]
while c < len(parent.children): # pyright: ignore[reportAttributeAccessIssue]
child = parent.children[c] # pyright: ignore[reportAttributeAccessIssue]
if (
isinstance(child, marko.block.Heading)
and hasattr(child, "children")
Expand All @@ -260,12 +260,12 @@ def _inflate_fragments(parent: marko.element.Element, origin_filename: str) -> N
doc = _get_test_step_fragment(absolute_path, child.level)
_update_links(doc, absolute_path)
_strip_link(child)
parent.children = (
parent.children[0 : c + 1] + doc.children + parent.children[c + 1 :]
parent.children = ( # pyright: ignore[reportAttributeAccessIssue]
parent.children[0 : c + 1] + doc.children + parent.children[c + 1 :] # pyright: ignore[reportAttributeAccessIssue]
)
c += len(doc.children)
elif isinstance(child, marko.element.Element):
_inflate_fragments(parent.children[c], origin_filename)
_inflate_fragments(parent.children[c], origin_filename) # pyright: ignore[reportAttributeAccessIssue]
c += 1
else:
c += 1
Expand All @@ -286,14 +286,14 @@ def add_resource_origin():
note = marko.parse(
"""&empty; _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:]
doc.children = doc.children[0:c] + note.children + doc.children[c:] # pyright: ignore[reportAttributeAccessIssue,reportOperatorIssue]
c += len(note.children)
return
# Insert resource origin information
origin = marko.parse(
f"\n\n&#x2705; Provided by {scenario.resource_origins[current_resource]}.\n"
)
doc.children = doc.children[0:c] + origin.children + doc.children[c:]
doc.children = doc.children[0:c] + origin.children + doc.children[c:] # pyright: ignore[reportOperatorIssue]
c += len(origin.children)

while c < len(doc.children):
Expand Down Expand Up @@ -327,11 +327,11 @@ def add_resource_origin():


def _strip_link(element: marko.element.Element) -> None:
if hasattr(element, "children") and element.children:
for c in range(len(element.children)):
child = element.children[c]
if hasattr(element, "children") and element.children: # pyright: ignore[reportAttributeAccessIssue]
for c in range(len(element.children)): # pyright: ignore[reportAttributeAccessIssue]
child = element.children[c] # pyright: ignore[reportAttributeAccessIssue]
if isinstance(child, marko.block.inline.Link):
element.children[c] = child.children[0]
element.children[c] = child.children[0] # pyright: ignore[reportAttributeAccessIssue]
elif isinstance(child, marko.element.Element):
_strip_link(child)

Expand Down Expand Up @@ -372,7 +372,7 @@ def add_context_to_case():
"""&empty; _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]
doc.children[0 : test_case_i0 + 1] # pyright: ignore[reportAttributeAccessIssue,reportOperatorIssue]
+ note.children
+ doc.children[test_case_i0 + 1 :]
)
Expand All @@ -394,7 +394,7 @@ def add_context_to_case():
test_case_i0 = c
test_case_level = child.level
for epoch in scenario.epochs:
if epoch.type != EpochType.Case:
if epoch.case is None:
continue
if case_name == epoch.case.name:
test_case = epoch.case
Expand All @@ -407,7 +407,7 @@ def add_context_to_case():
test_case_level = child.level
cleanup = True
for epoch in scenario.epochs:
if epoch.type != EpochType.Case:
if epoch.case is None:
continue
if len(epoch.case.steps) == 1 and epoch.case.steps[0].name == "Cleanup":
test_case = epoch.case
Expand Down Expand Up @@ -444,7 +444,7 @@ def add_context_to_step():
)
dc = len(note.children)
doc.children = (
doc.children[0 : test_step_i0 + 1]
doc.children[0 : test_step_i0 + 1] # pyright: ignore[reportOperatorIssue]
+ note.children
+ doc.children[test_step_i0 + 1 :]
)
Expand Down Expand Up @@ -494,6 +494,7 @@ def _add_context_to_step(
def add_context_to_check():
nonlocal c, i1, added, test_check_name, test_check_i0, test_check_level
if test_check_name is not None:
assert test_check_i0 is not None
dc = _add_context_to_check(doc, step, test_check_name, test_check_i0, c)
c += dc
i1 += dc
Expand Down Expand Up @@ -533,14 +534,14 @@ def _add_context_to_check(
check_text = [""]
for event in step.events:
if (
event.type == EventType.PassedCheck
event.passed_check is not None
and event.passed_check.name == test_check_name
):
check_text.append(
f"&#x2705; {', '.join(event.passed_check.participants)} ({event.passed_check.timestamp})"
)
elif (
event.type == EventType.FailedCheck
event.failed_check is not None
and event.failed_check.name == test_check_name
):
check_text.append(
Expand All @@ -552,7 +553,7 @@ def _add_context_to_check(
additions = marko.parse(
"""&empty; _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:]
doc.children = doc.children[0:i1] + additions.children + doc.children[i1:] # pyright: ignore[reportOperatorIssue]
return len(additions.children)


Expand All @@ -571,16 +572,16 @@ def _update_links(element: marko.element.Element, origin_filename: str) -> None:
url = url.replace("/github.com/", "/raw.githubusercontent.com/")
url = url.replace("/blob/", "/")
element.dest = url
if hasattr(element, "children") and element.children:
for child in element.children:
if hasattr(element, "children") and element.children: # pyright: ignore[reportAttributeAccessIssue]
for child in element.children: # pyright: ignore[reportAttributeAccessIssue]
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]
headings = [None]
headings: list[str | None] = [None]
prev_heading = None
for i, element in enumerate(elements):
if isinstance(element, marko.block.Heading):
Expand All @@ -599,7 +600,7 @@ def _add_section_numbers(elements: Sequence[marko.element.Element]) -> None:
heading_level += 1
else:
headings.append(text_of(element))
heading_trace = " -> ".join(headings)
heading_trace = " -> ".join([str(heading) for heading in headings])
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. Trace: {heading_trace}"
)
Expand All @@ -612,4 +613,4 @@ def _add_section_numbers(elements: Sequence[marko.element.Element]) -> None:
else:
element.children = [
marko.block.inline.RawText(section_number)
] + element.children
] + element.children # pyright: ignore[reportOperatorIssue]
Loading
Loading