-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[uss_qualifier] Improve action generator & test suite documentation (#…
…194) * Generate test suite documentation for action generators * Generate documentation for in-suite suite definitions * Remove orphaned documentation * Replace long arg lists with context * Add checked requirements * Add requirement implementation status * Explicitly preload module content * Fix tests
- Loading branch information
1 parent
fb503a3
commit 42751f5
Showing
31 changed files
with
2,434 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
40 changes: 40 additions & 0 deletions
40
monitoring/uss_qualifier/action_generators/documentation/definitions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Optional | ||
|
||
from implicitdict import ImplicitDict | ||
from monitoring.uss_qualifier.action_generators.definitions import GeneratorTypeName | ||
from monitoring.uss_qualifier.fileio import FileReference | ||
from monitoring.uss_qualifier.scenarios.definitions import TestScenarioTypeName | ||
from monitoring.uss_qualifier.suites.definitions import ActionType, TestSuiteDefinition | ||
|
||
|
||
class PotentialTestScenarioAction(ImplicitDict): | ||
scenario_type: TestScenarioTypeName | ||
"""Type of test scenario.""" | ||
|
||
|
||
class PotentialTestSuiteAction(ImplicitDict): | ||
suite_type: Optional[FileReference] | ||
"""Type/location of test suite. Usually expressed as the file name of the suite definition (without extension) qualified relative to the `uss_qualifier` folder""" | ||
|
||
suite_definition: Optional[TestSuiteDefinition] | ||
"""Definition of test suite internal to the configuration -- specified instead of `suite_type`.""" | ||
|
||
|
||
class PotentialActionGeneratorAction(ImplicitDict): | ||
generator_type: GeneratorTypeName | ||
"""Type of action generator.""" | ||
|
||
specification: dict | ||
"""Specification of action generator; format is the ActionGeneratorSpecificationType that corresponds to the `generator_type`""" | ||
|
||
|
||
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: | ||
ActionType.raise_invalid_action_declaration() | ||
return ActionType(matches[0]) |
78 changes: 78 additions & 0 deletions
78
monitoring/uss_qualifier/action_generators/documentation/documentation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from typing import List, Union | ||
|
||
from implicitdict import ImplicitDict | ||
from monitoring.uss_qualifier.action_generators.action_generator import ( | ||
action_generator_type_from_name, | ||
action_generator_specification_type, | ||
) | ||
from monitoring.uss_qualifier.action_generators.definitions import ( | ||
ActionGeneratorDefinition, | ||
) | ||
from monitoring.uss_qualifier.action_generators.documentation.definitions import ( | ||
PotentialGeneratedAction, | ||
PotentialTestScenarioAction, | ||
PotentialTestSuiteAction, | ||
PotentialActionGeneratorAction, | ||
) | ||
from monitoring.uss_qualifier.suites.definitions import ( | ||
TestSuiteActionDeclaration, | ||
ActionType, | ||
) | ||
|
||
|
||
def list_potential_actions_for_action_generator_definition( | ||
generator_def: Union[ActionGeneratorDefinition, PotentialActionGeneratorAction] | ||
) -> List[PotentialGeneratedAction]: | ||
action_generator_type = action_generator_type_from_name( | ||
generator_def.generator_type | ||
) | ||
specification_type = action_generator_specification_type(action_generator_type) | ||
if specification_type is not None: | ||
spec = ImplicitDict.parse(generator_def.specification, specification_type) | ||
else: | ||
spec = None | ||
return action_generator_type.list_potential_actions(spec) | ||
|
||
|
||
def list_potential_actions_for_action_declaration( | ||
declaration: TestSuiteActionDeclaration, | ||
) -> List[PotentialGeneratedAction]: | ||
action_type = declaration.get_action_type() | ||
if action_type == ActionType.TestScenario: | ||
return [ | ||
PotentialGeneratedAction( | ||
test_scenario=PotentialTestScenarioAction( | ||
scenario_type=declaration.test_scenario.scenario_type | ||
) | ||
) | ||
] | ||
elif action_type == ActionType.TestSuite: | ||
if "suite_type" in declaration.test_suite and declaration.test_suite.suite_type: | ||
return [ | ||
PotentialGeneratedAction( | ||
test_suite=PotentialTestSuiteAction( | ||
suite_type=declaration.test_suite.suite_type | ||
) | ||
) | ||
] | ||
elif ( | ||
"suite_definition" in declaration.test_suite | ||
and declaration.test_suite.suite_definition | ||
): | ||
return [ | ||
PotentialGeneratedAction( | ||
test_suite=PotentialTestSuiteAction( | ||
suite_definition=declaration.test_suite.suite_definition | ||
) | ||
) | ||
] | ||
elif action_type == ActionType.ActionGenerator: | ||
return [ | ||
PotentialGeneratedAction( | ||
action_generator=PotentialActionGeneratorAction( | ||
generator_type=declaration.action_generator.generator_type | ||
) | ||
) | ||
] | ||
else: | ||
raise NotImplementedError(f"Action type {action_type} is not supported") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.