mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 15:01:13 +00:00
5744ff65ac
- Add pytestmark = [pytest.mark.<category>] to all 23 root test files and 14 e2e test files - Marker distribution: 22 unit, 7 integration, 1 blackbox, 1 sitl, 5 e2e + 2 e2e integration - Add import pytest to test_models.py, test_download.py, test_synthetic_adapter.py (were missing) - Convert test_sitl_integration.py's bare pytestmark to list form preserving skipif guard - Union of all 5 markers = 298/298 = 100% coverage; 216 tests pass with --strict-markers
67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
"""MARSLVIGAdapter — reads pre-extracted per-topic files from a sequence dir."""
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
pytestmark = [pytest.mark.unit]
|
|
|
|
from gps_denied.testing.datasets.base import (
|
|
DatasetNotAvailableError,
|
|
PlatformClass,
|
|
)
|
|
from gps_denied.testing.datasets.mars_lvig import MARSLVIGAdapter
|
|
|
|
|
|
@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)
|