mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-04-23 05:36:36 +00:00
4822ddd30f
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
"""VPAIRAdapter unit tests with a fabricated vpair_sample/ layout."""
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from gps_denied.testing.datasets.base import (
|
|
DatasetNotAvailableError,
|
|
PlatformClass,
|
|
)
|
|
from gps_denied.testing.datasets.vpair import VPAIRAdapter
|
|
|
|
|
|
@pytest.fixture
|
|
def fake_vpair_root(tmp_path: Path) -> Path:
|
|
(tmp_path / "queries").mkdir()
|
|
for fn in ("q_00000.jpg", "q_00001.jpg"):
|
|
(tmp_path / "queries" / fn).write_bytes(b"\xff\xd8\xff\xd9") # minimal JPEG
|
|
(tmp_path / "poses.csv").write_text(
|
|
"filename,lat,lon,alt,qx,qy,qz,qw,timestamp_ns\n"
|
|
"q_00000.jpg,50.737,7.095,350.0,0,0,0,1,0\n"
|
|
"q_00001.jpg,50.7372,7.0952,350.0,0,0,0,1,1000000000\n"
|
|
)
|
|
return tmp_path
|
|
|
|
|
|
def test_raises_when_missing(tmp_path: Path):
|
|
with pytest.raises(DatasetNotAvailableError):
|
|
VPAIRAdapter(tmp_path / "nope")
|
|
|
|
|
|
def test_capabilities_no_raw_imu(fake_vpair_root: Path):
|
|
adapter = VPAIRAdapter(fake_vpair_root)
|
|
cap = adapter.capabilities
|
|
assert cap.has_raw_imu is False
|
|
assert cap.platform_class == PlatformClass.FIXED_WING
|
|
|
|
|
|
def test_iter_frames(fake_vpair_root: Path):
|
|
adapter = VPAIRAdapter(fake_vpair_root)
|
|
frames = list(adapter.iter_frames())
|
|
assert len(frames) == 2
|
|
assert Path(frames[0].image_path).name == "q_00000.jpg"
|
|
assert frames[1].timestamp_ns == 1_000_000_000
|
|
|
|
|
|
def test_iter_imu_empty(fake_vpair_root: Path):
|
|
adapter = VPAIRAdapter(fake_vpair_root)
|
|
assert list(adapter.iter_imu()) == []
|
|
|
|
|
|
def test_iter_ground_truth(fake_vpair_root: Path):
|
|
adapter = VPAIRAdapter(fake_vpair_root)
|
|
gt = list(adapter.iter_ground_truth())
|
|
assert len(gt) == 2
|
|
assert gt[0].lat == pytest.approx(50.737)
|
|
assert gt[0].alt == pytest.approx(350.0)
|