Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add summary to result file and update state machine checks #32

Merged
merged 2 commits into from
Sep 17, 2024
Merged
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
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions qc_otx/checks/core_checker/document_name_matches_filename.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ def check_rule(checker_data: models.CheckerData) -> None:
root_attrib = root.getroot().attrib

if "name" not in root_attrib:
logging.error("No name attribute find in otx root node. Abort...")

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"No name attribute in otx root node. Skip the check.",
)

return

document_name = root_attrib["name"]
Expand Down
25 changes: 18 additions & 7 deletions qc_otx/checks/core_checker/document_name_package_uniqueness.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,34 @@ def check_rule(checker_data: models.CheckerData) -> None:

document_name = root.get("name")
if document_name is None:
logging.error("No name attribute find in otx root node. Abort...")

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"No name attribute in otx root node. Skip the check.",
)

return

package_name = root.get("package")
if package_name is None:
logging.error("No package attribute find in otx root node. Abort...")

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
"No package attribute in otx root node. Skip the check.",
)

return

document_package_dot_name = package_name + "." + document_name
Expand Down Expand Up @@ -110,9 +118,6 @@ def check_rule(checker_data: models.CheckerData) -> None:
package_root = os.path.join(package_root, package_splits[0])

if not os.path.exists(package_root):
logging.error(
f"Error in setting package root {package_root}. Folder not found. Abort..."
)
os.chdir(previous_wd)

checker_data.result.set_checker_status(
Expand All @@ -121,6 +126,12 @@ def check_rule(checker_data: models.CheckerData) -> None:
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"The package root folder {package_root} does not exist. Skip the check.",
)

return
# Collect all otx file path from package root
package_otx_files = find_otx_files(package_root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,37 @@ def check_rule(checker_data: models.CheckerData) -> None:

source_data_model_version = utils.get_data_model_version(root)
if source_data_model_version is None:
logging.error(
"xmlns version not found in current document root. Skipping check.."
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"xmlns version not found in current document root. Skip the check.",
)

return

logging.debug(f"source_data_model_version: {source_data_model_version}")

import_nodes = root.findall(".//import", namespaces=root.nsmap)

if import_nodes is None:
logging.error("No import nodes found. Skipping check..")

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"No import nodes found. Skip the check.",
)

return

# Store previous working directory and move to config path dir for relative package paths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ def check_rule(checker_data: models.CheckerData) -> None:
import_nodes = root.findall(".//import", namespaces=root.nsmap)

if import_nodes is None:
logging.error("No import nodes found. Skipping check..")

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"No import nodes found. Skip the check.",
)

return

import_prefixes = [x.get("prefix") for x in import_nodes]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def check_rule(checker_data: models.CheckerData) -> None:
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"No state machine procedure prefix 'smp' found in document namespaces. Skip the check.",
)

return

state_machine_procedures = utils.get_state_machine_procedures(tree, nsmap)
Expand All @@ -56,6 +62,12 @@ def check_rule(checker_data: models.CheckerData) -> None:
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"State machine procedures not found. Skip the check.",
)

return

logging.debug(f"state_machine_procedures: {state_machine_procedures}")
Expand All @@ -66,30 +78,15 @@ def check_rule(checker_data: models.CheckerData) -> None:
state_machine = utils.get_state_machine(state_machine_procedure, nsmap)

if state_machine is None:
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

return
continue

smp_realisation = state_machine_procedure.xpath(
"./smp:realisation", namespaces=nsmap
)
logging.debug(f"smp_realisation: {smp_realisation}")

if smp_realisation is None or len(smp_realisation) != 1:
logging.error(
f"Invalid realisation found in current state machine procedure"
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)
return
continue

smp_realisation = smp_realisation[0]

Expand Down
25 changes: 13 additions & 12 deletions qc_otx/checks/state_machine_checker/mandatory_target_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,35 @@ def check_rule(checker_data: models.CheckerData) -> None:
nsmap = utils.get_namespace_map(tree)

if "smp" not in nsmap:
logging.error(
'No state machine procedure prefix "smp" found in document namespaces. Abort state machine procedure checks...'
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"No state machine procedure prefix 'smp' found in document namespaces. Skip the check.",
)

return

state_machine_procedures = utils.get_state_machine_procedures(tree, nsmap)

if state_machine_procedures is None:

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"State machine procedures not found. Skip the check.",
)

return

logging.debug(f"state_machine_procedures: {state_machine_procedures}")
Expand All @@ -63,13 +70,7 @@ def check_rule(checker_data: models.CheckerData) -> None:
state_machine = utils.get_state_machine(state_machine_procedure, nsmap)

if state_machine is None:
checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

return
continue

for sm_state in state_machine.states:
has_issue = (
Expand Down
26 changes: 13 additions & 13 deletions qc_otx/checks/state_machine_checker/mandatory_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,35 @@ def check_rule(checker_data: models.CheckerData) -> None:
nsmap = utils.get_namespace_map(tree)

if "smp" not in nsmap:
logging.error(
'No state machine procedure prefix "smp" found in document namespaces. Abort state machine procedure checks...'
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"No state machine procedure prefix 'smp' found in document namespaces. Skip the check.",
)

return

state_machine_procedures = utils.get_state_machine_procedures(tree, nsmap)

if state_machine_procedures is None:

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"State machine procedures not found. Skip the check.",
)

return

logging.debug(f"state_machine_procedures: {state_machine_procedures}")
Expand All @@ -65,14 +72,7 @@ def check_rule(checker_data: models.CheckerData) -> None:
state_machine = utils.get_state_machine(state_machine_procedure, nsmap)

if state_machine is None:

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

return
continue

for sm_state in state_machine.states:
has_issue = not sm_state.is_completed and len(sm_state.transitions) == 0
Expand Down
25 changes: 13 additions & 12 deletions qc_otx/checks/state_machine_checker/mandatory_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ def check_rule(checker_data: models.CheckerData) -> None:
nsmap = utils.get_namespace_map(tree)

if "smp" not in nsmap:
logging.error(
'No state machine procedure prefix "smp" found in document namespaces. Abort state machine procedure checks...'
)

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"No state machine procedure prefix 'smp' found in document namespaces. Skip the check.",
)

return

state_machine_procedures = utils.get_state_machine_procedures(tree, nsmap)
Expand All @@ -54,6 +56,12 @@ def check_rule(checker_data: models.CheckerData) -> None:
status=StatusType.SKIPPED,
)

checker_data.result.add_checker_summary(
constants.BUNDLE_NAME,
CHECKER_ID,
f"State machine procedures not found. Skip the check.",
)

return

logging.debug(f"state_machine_procedures: {state_machine_procedures}")
Expand All @@ -64,14 +72,7 @@ def check_rule(checker_data: models.CheckerData) -> None:
state_machine = utils.get_state_machine(state_machine_procedure, nsmap)

if state_machine is None:

checker_data.result.set_checker_status(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
status=StatusType.SKIPPED,
)

return
continue

for sm_state in state_machine.states:
has_issue = not sm_state.is_completed and len(sm_state.triggers) == 0
Expand Down
Loading