Skip to content
Merged
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
8 changes: 8 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ jobs:
if: ${{ steps.is-changed.outputs.changes == 'true'}}
run: uv run pytest --cov-report xml:coverage.xml --cov=t4_devkit

- name: Run CLIs
if: ${{ steps.is-changed.outputs.changes == 'true'}}
run: |
uv run t4viz scene ./tests/sample/t4dataset -o ./output
uv run t4viz instance ./tests/sample/t4dataset 90f0c98d1a040d5360847f576c5528f8 -o ./output
uv run t4viz pointcloud ./tests/sample/t4dataset -o ./output
uv run t4sanity ./tests/sample -iw
Comment thread
ktro2828 marked this conversation as resolved.

- name: Get test coverage
if: ${{ steps.is-changed.outputs.changes == 'true'}} && ${{ matrix.python-version == '3.10' }}
uses: orgoro/coverage@v3.1
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,8 @@ def dummy_camera_calibration() -> tuple[tuple[int, int], NDArrayFloat]:
)

return img_size, intrinsic


@pytest.fixture(scope="session")
def dummy_lanelet_path() -> str:
return "tests/sample/t4dataset/map/lanelet2_map.osm"

Copilot AI Sep 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using Path objects for file paths to improve cross-platform compatibility and consistency with other fixtures in the codebase.

Copilot uses AI. Check for mistakes.
5 changes: 2 additions & 3 deletions tests/lanelet/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from t4_devkit.lanelet import LaneletParser


def test_lanelet_parser() -> None:
def test_lanelet_parser(dummy_lanelet_path) -> None:
"""Test `LaneletParser`."""
lanelet_path = "tests/sample/map/lanelet2_map.osm"
_ = LaneletParser(lanelet_path)
_ = LaneletParser(dummy_lanelet_path)
File renamed without changes.
30 changes: 15 additions & 15 deletions tests/test_tier4.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@


@pytest.fixture(scope="session")
def sample_data_path() -> Path:
return Path(__file__).parent / "sample"
def sample_dataset_path() -> Path:
return Path(__file__).parent / "sample/t4dataset"


class TestDBMetadata:
Expand All @@ -26,26 +26,26 @@ def test_db_metadata_creation(self):
metadata = DBMetadata(
data_root="/path/to/data",
dataset_id="test_dataset",
version="v1.0",
version="1",
)

assert metadata.data_root == "/path/to/data"
assert metadata.dataset_id == "test_dataset"
assert metadata.version == "v1.0"
assert metadata.version == "1"


class TestLoadMetadata:
"""Test cases for load_metadata function."""

def test_load_metadata_with_status_file(self, sample_data_path):
def test_load_metadata_with_status_file(self, sample_dataset_path):
"""Test loading metadata when status.json exists."""
if not sample_data_path.exists():
if not sample_dataset_path.exists():
pytest.skip("Sample dataset not available")

metadata = load_metadata(sample_data_path.as_posix())
metadata = load_metadata(sample_dataset_path.as_posix())

assert metadata.data_root == sample_data_path.as_posix()
assert metadata.dataset_id == "sample"
assert metadata.data_root == sample_dataset_path.as_posix()
assert metadata.dataset_id == "t4dataset"
assert metadata.version is None

def test_load_metadata_without_status_file(self, tmp_path):
Expand All @@ -70,13 +70,13 @@ def test_load_metadata_with_specific_revision(self, tmp_path):
class TestLoadTable:
"""Test cases for load_table function."""

def test_load_table_success(self, sample_data_path):
def test_load_table_success(self, sample_dataset_path):
"""Test successful table loading."""
if not sample_data_path.exists():
if not sample_dataset_path.exists():
pytest.skip("Sample dataset not available")

# Create a dummy annotation file
annotation_dir = sample_data_path.joinpath("annotation")
annotation_dir = sample_dataset_path.joinpath("annotation")

result = load_table(annotation_dir.as_posix(), SchemaName.ATTRIBUTE)

Expand Down Expand Up @@ -109,10 +109,10 @@ class TestTier4:
@pytest.fixture(scope="class")
def sample_t4(self):
"""Create a Tier4 instance using the real sample dataset."""
sample_data_path = Path(__file__).parent / "sample"
if not sample_data_path.exists():
sample_dataset_path = Path(__file__).parent / "sample/t4dataset"
if not sample_dataset_path.exists():
pytest.skip("Sample dataset not available")
return Tier4(sample_data_path.as_posix(), verbose=False)
return Tier4(sample_dataset_path.as_posix(), verbose=False)

def test_dataset_structure_validation(self, sample_t4):
"""Validate the complete structure of the sample dataset."""
Expand Down
5 changes: 2 additions & 3 deletions tests/viewer/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def test_render_calibration(dummy_viewer, dummy_camera_calibration) -> None:
dummy_viewer.render_calibration(sensor, calibration)


def test_render_map(dummy_viewer) -> None:
def test_render_map(dummy_viewer, dummy_lanelet_path) -> None:
"""Test rendering map with `RerunViewer`."""
lanelet_path = "tests/sample/map/lanelet2_map.osm"
dummy_viewer.render_map(lanelet_path)
dummy_viewer.render_map(dummy_lanelet_path)
Loading