Files
gps-denied-onboard/tests/blackbox/test_still_image_replay.py
T
Oleksandr Bezdieniezhnykh 5acd14b792 [AZ-234] [AZ-235] [AZ-236] [AZ-237] Add replay tests
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-05 06:24:10 +03:00

69 lines
2.3 KiB
Python

from pathlib import Path
import pytest
from e2e.replay.harness import (
ReplayEstimate,
evaluate_still_image_estimates,
load_expected_coordinates,
)
def test_expected_coordinate_loader_rejects_invalid_wgs84_rows(tmp_path: Path) -> None:
# Arrange
coordinates_path = tmp_path / "coordinates.csv"
coordinates_path.write_text("image, lat, lon\nAD000001.jpg, 120.0, 37.0\n", encoding="utf-8")
# Act / Assert
with pytest.raises(ValueError, match="outside WGS84 bounds"):
load_expected_coordinates(coordinates_path)
def test_still_image_replay_reports_coordinate_thresholds_and_latency() -> None:
# Arrange
expected = load_expected_coordinates(Path("_docs/00_problem/input_data/coordinates.csv"))
estimates = tuple(
ReplayEstimate(
image_ref=coordinate.image_ref,
latitude_deg=coordinate.latitude_deg + 0.00001,
longitude_deg=coordinate.longitude_deg + 0.00001,
covariance_95_semi_major_m=8.0,
source_label="satellite_anchored",
anchor_age_ms=150,
capture_to_output_latency_ms=40.0 + index,
)
for index, coordinate in enumerate(expected)
)
# Act
metrics = evaluate_still_image_estimates(expected, estimates)
# Assert
assert metrics["threshold_passed"] is True
assert metrics["within_50_m_rate"] >= 0.80
assert metrics["within_20_m_rate"] >= 0.50
assert metrics["p50_latency_ms"] > 0.0
assert metrics["p95_latency_ms"] >= metrics["p50_latency_ms"]
assert metrics["p99_latency_ms"] >= metrics["p95_latency_ms"]
assert metrics["dropped_frame_rate"] == 0.0
def test_confidence_contract_validation_fails_missing_source_label() -> None:
# Arrange
expected = load_expected_coordinates(Path("_docs/00_problem/input_data/coordinates.csv"))[:1]
estimates = (
ReplayEstimate(
image_ref=expected[0].image_ref,
latitude_deg=expected[0].latitude_deg,
longitude_deg=expected[0].longitude_deg,
covariance_95_semi_major_m=8.0,
source_label="",
anchor_age_ms=0,
capture_to_output_latency_ms=10.0,
),
)
# Act / Assert
with pytest.raises(ValueError, match="source label is missing"):
evaluate_still_image_estimates(expected, estimates)