Skip to content

Commit

Permalink
Add get checker status function
Browse files Browse the repository at this point in the history
Signed-off-by: hoangtungdinh <[email protected]>
  • Loading branch information
hoangtungdinh committed Sep 11, 2024
1 parent 7c1825e commit 1e4ec8b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
11 changes: 11 additions & 0 deletions qc_baselib/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,14 @@ def all_checkers_completed_without_issue(self, check_id_set: Set[str]) -> bool:
result = result and checker_result

return result

def get_checker_status(self, checker_id: str) -> Union[None, StatusType]:
"""
Return None if the checker is not found.
"""
for bundle in self._report_results.checker_bundles:
for checker in bundle.checkers:
if checker.checker_id == checker_id:
return checker.status

return None
45 changes: 45 additions & 0 deletions tests/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,3 +920,48 @@ def test_registration_without_summary() -> None:
)

assert True


def test_get_checker_status() -> None:
result_report = Result()

result_report.register_checker_bundle(
name="TestBundle",
build_date="2024-05-31",
description="Example checker bundle",
version="0.0.1",
)

assert result_report.get_checker_status("TestChecker") == None

result_report.register_checker(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
description="",
)

assert result_report.get_checker_status("TestChecker") == None

result_report.set_checker_status(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
status=StatusType.COMPLETED,
)

assert result_report.get_checker_status("TestChecker") == StatusType.COMPLETED

result_report.set_checker_status(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
status=StatusType.SKIPPED,
)

assert result_report.get_checker_status("TestChecker") == StatusType.SKIPPED

result_report.set_checker_status(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
status=StatusType.ERROR,
)

assert result_report.get_checker_status("TestChecker") == StatusType.ERROR

0 comments on commit 1e4ec8b

Please sign in to comment.