Skip to content

Commit

Permalink
Update tests to work with new schema restrictions
Browse files Browse the repository at this point in the history
Signed-off-by: patrickpa <[email protected]>
  • Loading branch information
patrickpa committed Jun 10, 2024
1 parent e8e56e8 commit 5410c96
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 3 deletions.
29 changes: 29 additions & 0 deletions tests/data/demo_checker_bundle_extended.xqar
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<CheckerResults version="1.0.0">

<CheckerBundle build_date="" description="" name="DemoCheckerBundle" summary="Found 3 issues" version="">
<Checker checkerId="exampleChecker" description="This is a description" status="completed" summary="">
<AddressedRule ruleUID="test.com:qc:1.0.0:qwerty.qwerty"/>
<Issue description="This is an information from the demo usecase" issueId="0" level="3" ruleUID="test.com:qc:1.0.0:qwerty.qwerty"/>
</Checker>
<Checker checkerId="exampleInertialChecker" description="This is a description of inertial checker" status="completed" summary="">
<AddressedRule ruleUID="test.com:qc:1.0.0:qwerty.qwerty"/>
<Issue description="This is an information from the demo usecase" issueId="1" level="3" ruleUID="test.com:qc:1.0.0:qwerty.qwerty">
<Locations description="inertial position">
<InertialLocation x="1.000000" y="2.000000" z="3.000000"/>
</Locations>
</Issue>
</Checker>
<Checker checkerId="exampleRuleUIDChecker" description="This is a description of ruleUID checker" status="completed" summary="">
<AddressedRule ruleUID="test.com:qc:1.0.0:qwerty.qwerty"/>
<Metadata description="Date in which the checker was executed" key="run date" value="2024/06/06"/>
<Metadata description="Name of the project that created the checker" key="reference project" value="project01"/>
</Checker>
<Checker checkerId="exampleIssueRuleChecker" description="This is a description of checker with issue and the involved ruleUID" status="completed" summary="">
<AddressedRule ruleUID="test.com:qc:1.0.0:qwerty.qwerty"/>
<Issue description="This is an information from the demo usecase" issueId="2" level="1" ruleUID="test.com:qc:1.0.0:qwerty.qwerty"/>
</Checker>
<Checker checkerId="exampleSkippedChecker" description="This is a description of checker with skipped status" status="skipped" summary="Skipped execution"/>
</CheckerBundle>

</CheckerResults>
5 changes: 3 additions & 2 deletions tests/data/result_test_output.xqar
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<CheckerResults version="0.0.1">
<CheckerBundle build_date="2024-05-31" description="Example checker bundle" name="TestBundle" version="0.0.1" summary="Tested example checkers">
<Checker checkerId="TestChecker" description="Test checker" summary="Executed evaluation">
<Issue issueId="0" description="Issue found at odr" level="3">
<Checker status="completed" checkerId="TestChecker" description="Test checker" summary="Executed evaluation">
<AddressedRule ruleUID="test.com:qc:1.0.0:qwerty.qwerty"/>
<Issue issueId="0" description="Issue found at odr" level="3" ruleUID="test.com:qc:1.0.0:qwerty.qwerty">
<Location description="Location for issue">
<FileLocation column="0" row="1" fileType="odr"/>
</Location>
Expand Down
76 changes: 75 additions & 1 deletion tests/test_result.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
import pytest
from qc_baselib.models import config, result
from qc_baselib import Result, IssueSeverity
from qc_baselib import Result, IssueSeverity, StatusType


DEMO_REPORT_PATH = "tests/data/demo_checker_bundle.xqar"
EXTENDED_DEMO_REPORT_PATH = "tests/data/demo_checker_bundle_extended.xqar"
EXAMPLE_OUTPUT_REPORT_PATH = "tests/data/result_test_output.xqar"
TEST_REPORT_OUTPUT_PATH = "tests/result_test_output.xqar"

Expand All @@ -22,6 +23,12 @@ def test_load_result_from_file() -> None:
assert len(result._report_results.to_xml()) > 0


def test_load_result_from_extended_file() -> None:
result = Result()
result.load_from_file(EXTENDED_DEMO_REPORT_PATH)
assert len(result._report_results.to_xml()) > 0


def test_result_write() -> None:
result = Result()

Expand All @@ -40,11 +47,21 @@ def test_result_write() -> None:
summary="Executed evaluation",
)

rule_uid = result.register_rule(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
emanating_entity="test.com",
standard="qc",
definition_setting="1.0.0",
rule_full_name="qwerty.qwerty",
)

issue_id = result.register_issue(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
description="Issue found at odr",
level=IssueSeverity.INFORMATION,
rule_uid=rule_uid,
)

result.add_file_location(
Expand All @@ -64,6 +81,12 @@ def test_result_write() -> None:
description="Location for issue",
)

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

result.write_to_file(TEST_REPORT_OUTPUT_PATH)

example_xml_text = ""
Expand Down Expand Up @@ -148,19 +171,70 @@ def test_result_register_issue_id_generation() -> None:
summary="Executed evaluation",
)

rule_uid = result.register_rule(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
emanating_entity="test.com",
standard="qc",
definition_setting="1.0.0",
rule_full_name="qwerty.qwerty",
)

issue_id_0 = result.register_issue(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
description="Issue found at odr",
level=IssueSeverity.INFORMATION,
rule_uid=rule_uid,
)

issue_id_1 = result.register_issue(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
description="Issue found at odr",
level=IssueSeverity.INFORMATION,
rule_uid=rule_uid,
)

assert issue_id_0 != issue_id_1
assert issue_id_0 == issue_id_1 - 1


def test_create_issue_load_id() -> None:
result = Result()

result.register_checker_bundle(
name="TestBundle",
build_date="2024-05-31",
description="Example checker bundle",
version="0.0.1",
summary="Tested example checkers",
)

result.register_checker(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
description="Test checker",
summary="Executed evaluation",
)

rule_uid = result.register_rule(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
emanating_entity="test.com",
standard="qc",
definition_setting="1.0.0",
rule_full_name="qwerty.qwerty",
)

assert rule_uid == "test.com:qc:1.0.0:qwerty.qwerty"

issue_id = result.register_issue(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
description="Issue found at odr",
level=IssueSeverity.INFORMATION,
rule_uid=rule_uid,
)

assert issue_id == 0

0 comments on commit 5410c96

Please sign in to comment.