Skip to content
Open
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
220 changes: 211 additions & 9 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.10"
asam-qc-baselib = {git = "https://github.com/asam-ev/qc-baselib-py.git", rev = "main"}
open-simulation-interface = {git = "https://github.com/OpenSimulationInterface/open-simulation-interface.git", rev = "v3.7.0"}
osi-python = {git = "https://github.com/OpenSimulationInterface/osi-python.git", rev = "temp/osi3trace-mcap-support-fix"}
pyyaml = "^6.0.0"
iso3166 = "^2.1.1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def run_checks(config: Configuration, result: Result) -> None:
expected_type = OSITrace.map_message_type(expected_type_name)

trace = OSITrace(
config.get_config_param("InputFile"), config.get_config_param("osiType")
config.get_config_param("InputFile"),
config.get_config_param("osiType"),
False,
config.get_config_param("osiTopic"),
)

result.register_checker(
Expand Down
7 changes: 6 additions & 1 deletion qc_ositrace/checks/osirules/osirules_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,12 @@ def run_checks(config: Configuration, result: Result) -> None:
)
expected_type_name = config.get_config_param("osiType")

trace = OSITrace(config.get_config_param("InputFile"), expected_type_name)
trace = OSITrace(
config.get_config_param("InputFile"),
expected_type_name,
False,
config.get_config_param("osiTopic"),
)

result.register_checker(
checker_bundle_name=constants.BUNDLE_NAME,
Expand Down
8 changes: 8 additions & 0 deletions qc_ositrace/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def args_entrypoint() -> argparse.Namespace:
type=pathlib.Path,
help="Path to the input OSI Trace file.",
)
parser.add_argument(
"--osiTopic",
type=str,
help="Channel topic of a multi-trace OSI Trace file to select.",
)
parser.add_argument(
"--osiType",
type=str,
Expand Down Expand Up @@ -101,6 +106,9 @@ def main():
logging.info("Setting input file: %s", args.input_file)
config.set_config_param("InputFile", str(args.input_file))

if args.osiTopic:
logging.info("Setting OSI Topic: %s", args.osiTopic)
config.set_config_param("osiTopic", args.osiTopic)
if args.osiType:
logging.info("Setting OSI Type: %s", args.osiType)
config.set_config_param("osiType", args.osiType)
Expand Down
Binary file not shown.
34 changes: 34 additions & 0 deletions tests/test_deserialization_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,37 @@ def test_deserialization_expected_version(
launch_main(monkeypatch)
check_issues(rule_uid, issue_count, issue_severity)
cleanup_files()


@pytest.mark.parametrize(
"target_file,target_topic,target_type,target_version,issue_count",
[
("360", "MySensorView", "SensorView", "3.5.0", 547),
("360", "MySensorView", "SensorView", "3.6.0", 0),
("360", "Foo", "SensorView", "3.6.0", -1),
],
)
def test_deserialization_mcap_topic(
target_file: str,
target_topic: str,
target_type: str,
target_version: str,
issue_count: int,
monkeypatch,
) -> None:
base_path = "tests/data/deserialization_expected_version/"
target_file_name = f"deserialization_expected_version_{target_file}.mcap"
rule_uid = "asam.net:osi:3.0.0:deserialization.expected_version"
issue_severity = IssueSeverity.ERROR

target_file_path = os.path.join(base_path, target_file_name)
create_test_config(
target_file_path, target_type, target_version, None, target_topic
)
if issue_count < 0:
with pytest.raises(ValueError):
launch_main(monkeypatch)
else:
launch_main(monkeypatch)
check_issues(rule_uid, issue_count, issue_severity)
cleanup_files()
14 changes: 14 additions & 0 deletions tests/test_osirules_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ def test_osirules_expected_version(
"sensorview.mounting_position.is_set",
547,
),
(
"deserialization_expected_version/deserialization_expected_version_360.mcap",
"SensorView",
"3.6.0",
"sensorview.mounting_position.is_set",
0,
),
(
"deserialization_expected_version/deserialization_expected_version_360.mcap",
"SensorView",
"3.7.0",
"sensorview.mounting_position.is_set",
547,
),
],
)
def test_osirules_automatic_rules(
Expand Down
10 changes: 8 additions & 2 deletions tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from typing import Optional

from contextlib import suppress

import qc_ositrace.main as main

from qc_ositrace import constants
Expand All @@ -17,6 +19,7 @@ def create_test_config(
target_file_type: str,
target_file_version: Optional[str] = None,
target_file_rules: Optional[str] = None,
target_file_topic: Optional[str] = None,
):
test_config = Configuration()
test_config.set_config_param(name="InputFile", value=target_file_path)
Expand All @@ -25,6 +28,8 @@ def create_test_config(
test_config.set_config_param(name="osiVersion", value=target_file_version)
if target_file_rules is not None:
test_config.set_config_param(name="osiRulesFile", value=target_file_rules)
if target_file_topic is not None:
test_config.set_config_param(name="osiTopic", value=target_file_topic)
test_config.register_checker_bundle(checker_bundle_name=constants.BUNDLE_NAME)
test_config.set_checker_bundle_param(
checker_bundle_name=constants.BUNDLE_NAME,
Expand Down Expand Up @@ -61,5 +66,6 @@ def launch_main(monkeypatch):


def cleanup_files():
os.remove(REPORT_FILE_PATH)
os.remove(CONFIG_FILE_PATH)
with suppress(Exception):
os.remove(REPORT_FILE_PATH)
os.remove(CONFIG_FILE_PATH)