Skip to content

Commit

Permalink
Add test cases for check 6
Browse files Browse the repository at this point in the history
Signed-off-by: romanodanilo <[email protected]>
  • Loading branch information
romanodanilo committed Jul 19, 2024
1 parent 453b39e commit f832a84
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/data/Core_Chk006/Core_Chk006_negative.otx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<! <!-- Inserted rule violatio - This document has version 2.0.0 but imported document is with version
<!-- Inserted rule violatio - This document has version 2.0.0 but imported document is with version
1.0.0-->
<otx xmlns="http://iso.org/OTX/2.0.0" id="2"
name="Core_Chk006_negative"
Expand Down
45 changes: 45 additions & 0 deletions tests/test_core_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,51 @@ def test_chk005_negative(
test_utils.cleanup_files()


def test_chk006_positive(
monkeypatch,
) -> None:
base_path = "tests/data/Core_Chk006"
target_file_name = f"Core_Chk006_positive.otx"
target_file_path = os.path.join(base_path, target_file_name)

test_utils.create_test_config(target_file_path)

test_utils.launch_main(monkeypatch)

result = Result()
result.load_from_file(test_utils.REPORT_FILE_PATH)

core_issues = result.get_issues_by_rule_uid(
"asam.net:otx:1.0.0:core.chk_006.match_of_imported_document_data_model_version"
)
assert len(core_issues) == 0
test_utils.cleanup_files()


def test_chk006_negative(
monkeypatch,
) -> None:
base_path = "tests/data/Core_Chk006"
target_file_name = f"Core_Chk006_negative.otx"
target_file_path = os.path.join(base_path, target_file_name)

test_utils.create_test_config(target_file_path)

test_utils.launch_main(monkeypatch)

result = Result()
result.load_from_file(test_utils.REPORT_FILE_PATH)

core_issues = result.get_issues_by_rule_uid(
"asam.net:otx:1.0.0:core.chk_006.match_of_imported_document_data_model_version"
)
assert len(core_issues) == 1
assert core_issues[0].level == IssueSeverity.ERROR
assert "1.0.0" in core_issues[0].locations[0].description

test_utils.cleanup_files()


def test_chk007_positive(
monkeypatch,
) -> None:
Expand Down

0 comments on commit f832a84

Please sign in to comment.