From 0078322fee39b607db7f887da9aa9a8bf25a6b44 Mon Sep 17 00:00:00 2001 From: Tobias Klockau Date: Fri, 20 Oct 2023 15:50:16 +0200 Subject: [PATCH] test: add fixtures for onthology and scenes --- .../validation/conftest.py | 9 +++++ .../test_validate_onthology.py | 37 +++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 tests/test_raillabel_providerkit/validation/conftest.py diff --git a/tests/test_raillabel_providerkit/validation/conftest.py b/tests/test_raillabel_providerkit/validation/conftest.py new file mode 100644 index 0000000..cfdf202 --- /dev/null +++ b/tests/test_raillabel_providerkit/validation/conftest.py @@ -0,0 +1,9 @@ +# Copyright DB Netz AG and contributors +# SPDX-License-Identifier: Apache-2.0 + +from validate_onthology.test_validate_onthology import ( + demo_onthology, + invalid_onthology_scene, + metadata, + valid_onthology_scene, +) diff --git a/tests/test_raillabel_providerkit/validation/validate_onthology/test_validate_onthology.py b/tests/test_raillabel_providerkit/validation/validate_onthology/test_validate_onthology.py index 0ff0138..53baa7f 100644 --- a/tests/test_raillabel_providerkit/validation/validate_onthology/test_validate_onthology.py +++ b/tests/test_raillabel_providerkit/validation/validate_onthology/test_validate_onthology.py @@ -39,10 +39,6 @@ def build_scene( } ) -@pytest.fixture -def metadata(): - return raillabel.format.Metadata(schema_version="1.0.0") - @pytest.fixture def sensors() -> t.List[raillabel.format.Sensor]: return { @@ -93,6 +89,39 @@ def build_annotation( size=[], ) +# == Fixtures ========================= + +@pytest.fixture +def metadata(): + return raillabel.format.Metadata(schema_version="1.0.0") + +@pytest.fixture +def demo_onthology() -> dict: + return { + "person": {}, + "train": {}, + } + +@pytest.fixture +def valid_onthology_scene(metadata) -> raillabel.Scene: + return raillabel.format.Scene( + metadata=metadata, + objects=make_dict_with_uids([ + build_object("person"), + build_object("person"), + build_object("train"), + ]) + ) + +@pytest.fixture +def invalid_onthology_scene(metadata) -> raillabel.Scene: + return raillabel.format.Scene( + metadata=metadata, + objects=make_dict_with_uids([ + build_object("INVALID_CLASS"), + ]) + ) + # == Tests ============================ def test_onthology_schema_invalid():