"""Tests for the AZ-407 cold-boot fixture. AC-4 (SITL loads pose within ±1 m) requires SITL which the unit-test layer cannot run; that path is covered by AZ-419's FT-P-11 inside the Docker-bound runner. AZ-407's unit-test obligation is to verify the JSON shape and bounds. """ from __future__ import annotations import json from pathlib import Path import pytest REPO_ROOT = Path(__file__).resolve().parents[3] FIXTURE_PATH = REPO_ROOT / "e2e" / "fixtures" / "cold-boot" / "cold_boot_fixture.json" @pytest.fixture(scope="module") def cold_boot() -> dict: return json.loads(FIXTURE_PATH.read_text()) def test_schema_version(cold_boot: dict) -> None: """The schema field locks the file shape; AZ-419's loader keys off it.""" # Assert assert cold_boot["_schema"] == "cold-boot-fixture/v1" def test_global_position_int_block(cold_boot: dict) -> None: """GLOBAL_POSITION_INT fields use canonical MAVLink units.""" # Arrange gpi = cold_boot["global_position_int"] # Assert required = { "time_boot_ms", "lat_e7", "lon_e7", "alt_mm", "relative_alt_mm", "vx_cm_s", "vy_cm_s", "vz_cm_s", "hdg_cdeg", } assert required <= set(gpi), f"missing fields: {required - set(gpi)}" assert -90 * 10**7 <= gpi["lat_e7"] <= 90 * 10**7 assert -180 * 10**7 <= gpi["lon_e7"] <= 180 * 10**7 assert -50_000_000 <= gpi["alt_mm"] <= 50_000_000 def test_attitude_block(cold_boot: dict) -> None: """Attitude angles fall inside [-pi, pi].""" # Arrange att = cold_boot["attitude"] import math # Assert for field in ("roll_rad", "pitch_rad", "yaw_rad"): assert -math.pi <= att[field] <= math.pi, f"{field} out of range: {att[field]}" def test_derkachi_lat_lon_inside_bbox(cold_boot: dict) -> None: """The frozen pose must be inside the Derkachi route bbox used by C2.""" # Arrange lat = cold_boot["global_position_int"]["lat_e7"] / 10**7 lon = cold_boot["global_position_int"]["lon_e7"] / 10**7 # Assert assert 50.05 <= lat <= 50.10, f"lat {lat} outside Derkachi bbox" assert 36.10 <= lon <= 36.20, f"lon {lon} outside Derkachi bbox" def test_provenance_block_present(cold_boot: dict) -> None: """AC-7: license + provenance fields documented inside the JSON itself.""" # Assert assert "_license" in cold_boot assert "_provenance" in cold_boot assert "AZ-419" in cold_boot["_authored_for"][1]