Files
gps-denied-onboard/tests/e2e/test_mars_lvig_adapter.py
T
Yuzviak bf5b0e3ae2 fix(lint): resolve all ruff E402/I001/F821 errors
- Move pytestmark after all imports in 35 test files (E402: not-at-top)
- Add TYPE_CHECKING guard for FlightProcessor in composition.py (F821)
- Sort import blocks in src/ and tests/ (I001 auto-fix via ruff --fix)
- ruff check src/ tests/ now exits 0 with no errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 19:13:42 +03:00

67 lines
1.9 KiB
Python

"""MARSLVIGAdapter — reads pre-extracted per-topic files from a sequence dir."""
from pathlib import Path
import pytest
from gps_denied.testing.datasets.base import (
DatasetNotAvailableError,
PlatformClass,
)
from gps_denied.testing.datasets.mars_lvig import MARSLVIGAdapter
pytestmark = [pytest.mark.unit]
@pytest.fixture
def fake_mars_seq(tmp_path: Path) -> Path:
seq = tmp_path / "HKairport_01"
(seq / "images").mkdir(parents=True)
for ts in (100_000_000, 200_000_000):
(seq / "images" / f"{ts}.jpg").write_bytes(b"\xff\xd8\xff\xd9")
(seq / "imu.csv").write_text(
"timestamp_ns,ax,ay,az,gx,gy,gz\n"
"100000000,0.0,0.0,-9.81,0.0,0.0,0.0\n"
"200000000,0.0,0.0,-9.81,0.0,0.0,0.0\n"
)
(seq / "gnss.csv").write_text(
"timestamp_ns,lat,lon,alt\n"
"100000000,22.32,114.17,100.0\n"
"200000000,22.3201,114.1702,100.0\n"
)
return seq
def test_raises_when_missing(tmp_path: Path):
with pytest.raises(DatasetNotAvailableError):
MARSLVIGAdapter(tmp_path / "nope")
def test_capabilities(fake_mars_seq: Path):
adapter = MARSLVIGAdapter(fake_mars_seq)
cap = adapter.capabilities
assert cap.has_raw_imu is True
assert cap.has_rtk_gt is True
assert cap.platform_class == PlatformClass.ROTARY
def test_iter_frames(fake_mars_seq: Path):
adapter = MARSLVIGAdapter(fake_mars_seq)
frames = list(adapter.iter_frames())
assert len(frames) == 2
assert frames[0].timestamp_ns == 100_000_000
def test_iter_imu(fake_mars_seq: Path):
adapter = MARSLVIGAdapter(fake_mars_seq)
imu = list(adapter.iter_imu())
assert len(imu) == 2
assert imu[0].accel == (0.0, 0.0, -9.81)
def test_iter_ground_truth(fake_mars_seq: Path):
adapter = MARSLVIGAdapter(fake_mars_seq)
gt = list(adapter.iter_ground_truth())
assert len(gt) == 2
assert gt[0].lat == pytest.approx(22.32)