Files
gps-denied-onboard/tests/unit/test_ac1_scaffold_layout.py
T
Oleksandr Bezdieniezhnykh 5fe67023b2 [AZ-329] [AZ-330] [AZ-523] [AZ-524] Batch 44 atomic refactor
Implements two new C12 services and rebalances the C11/C12 boundary
in one atomic commit:

* AZ-329 PostLandingUploadOrchestrator — gates C11 upload on the
  `flight_footer` FDR record's `clean_shutdown` field; 4 refusal
  modes; new FdrFooterReader Protocol + LocalFdrFooterReader.
* AZ-330 OperatorReLocService — AC-3.4 visual-loss re-localization
  hint; reuses shared LatLonAlt; OperatorCommandTransport Protocol
  cut (E-C8 owns the future pymavlink concrete); new FDR record
  kind `c12.reloc.requested`; log redaction (lat/lon 5 decimals,
  reason 200 chars).
* AZ-523 C11 internal flight-state gate removed (SRP refactor):
  `confirm_flight_state` / `FlightStateSignal` use /
  `FlightStateNotOnGroundError` deleted from C11; TileUploader
  contract bumped to v2.0.0 (frozen) with migration note; AZ-317
  superseded.
* AZ-524 Package rename `c12_operator_tooling` →
  `c12_operator_orchestrator` across source, tests, pyproject,
  CMake, Dockerfile, compose, CI, runtime-root services class
  (`OperatorOrchestratorServices`) + factory function
  (`build_operator_orchestrator`), logger namespaces, config slug,
  docs, and the E-C12 epic title.

Tests: 1543 passed, 80 skipped (all environment gates). Targeted
AC suite (AZ-329 + AZ-330 + FdrFooterReader): 37 passed. Cold-start
NFR-perf still ≤ 500 ms p99.

Tracker: AZ-317 → Done (superseded); AZ-319 v2.0.0 contract bump
comment; AZ-329/AZ-330 → In Testing; AZ-253 epic renamed; AZ-523
+ AZ-524 created and closed as audit-trail tickets.

See `_docs/03_implementation/batch_44_cycle1_report.md`.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 19:42:46 +03:00

141 lines
4.0 KiB
Python

"""AC-1: project scaffolded matching the layout in AZ-263.
Validates folder/file presence + that `pyproject.toml` and the top-level
`CMakeLists.txt` + `cmake/{dependencies,build_options}.cmake` parse without
error. The CMake configure step is gated on `cmake` being on PATH; when it
isn't, the test skips with an explicit prerequisite reason.
"""
from __future__ import annotations
import shutil
import subprocess
import sys
from pathlib import Path
import pytest
REPO_ROOT = Path(__file__).resolve().parents[2]
REQUIRED_PATHS: tuple[str, ...] = (
"pyproject.toml",
"CMakeLists.txt",
"cmake/dependencies.cmake",
"cmake/build_options.cmake",
"cmake/strategies.cmake",
".clang-format",
".clang-tidy",
".cmake-format.yaml",
".editorconfig",
".env.example",
".dockerignore",
".gitignore",
"README.md",
"docker/companion-tier1.Dockerfile",
"docker/operator-orchestrator.Dockerfile",
"docker/mock-suite-sat-service.Dockerfile",
"docker-compose.yml",
"docker-compose.test.yml",
".github/workflows/ci.yml",
".github/workflows/ci-tier2.yml",
".github/workflows/release.yml",
".github/workflows/cve-rescan.yml",
"ci/sbom_diff.py",
"ci/opencv_pin_gate.py",
"src/gps_denied_onboard/__init__.py",
"src/gps_denied_onboard/runtime_root/__init__.py",
"src/gps_denied_onboard/healthcheck.py",
"src/gps_denied_onboard/_types/__init__.py",
"src/gps_denied_onboard/helpers/__init__.py",
"src/gps_denied_onboard/logging/structured.py",
"src/gps_denied_onboard/config/loader.py",
"src/gps_denied_onboard/fdr_client/client.py",
"alembic.ini",
"db/migrations/env.py",
"db/migrations/versions/0001_initial.py",
"scripts/run-tests.sh",
"scripts/run-performance-tests.sh",
)
COMPONENT_DIRS: tuple[str, ...] = (
"c1_vio",
"c2_vpr",
"c2_5_rerank",
"c3_matcher",
"c3_5_adhop",
"c4_pose",
"c5_state",
"c6_tile_cache",
"c7_inference",
"c8_fc_adapter",
"c10_provisioning",
"c11_tile_manager",
"c12_operator_orchestrator",
"c13_fdr",
)
@pytest.mark.parametrize("rel_path", REQUIRED_PATHS)
def test_required_path_exists(rel_path: str) -> None:
# Assert
assert (REPO_ROOT / rel_path).exists(), f"missing required path: {rel_path}"
@pytest.mark.parametrize("component", COMPONENT_DIRS)
def test_component_has_interface_and_init(component: str) -> None:
# Assert
comp_root = REPO_ROOT / "src" / "gps_denied_onboard" / "components" / component
assert (comp_root / "__init__.py").exists(), f"missing __init__.py for {component}"
assert (comp_root / "interface.py").exists(), f"missing interface.py for {component}"
def test_pyproject_toml_parses() -> None:
# Arrange
if sys.version_info >= (3, 11):
import tomllib
else:
try:
import tomli as tomllib # type: ignore[no-redef]
except ImportError: # pragma: no cover - tomli installed in dev extras
pytest.skip("tomli/tomllib not available")
# Act
data = tomllib.loads((REPO_ROOT / "pyproject.toml").read_text())
# Assert
assert data["project"]["name"] == "gps-denied-onboard"
assert any(dep.startswith("opencv-python") for dep in data["project"]["dependencies"]), (
"opencv-python pin must be in dependencies"
)
def test_cmake_files_configure() -> None:
# Arrange
cmake = shutil.which("cmake")
if cmake is None:
pytest.skip("cmake not on PATH; CI image installs cmake (Tier-1 ci.yml)")
build_dir = REPO_ROOT / "build" / "ac1_smoke"
build_dir.mkdir(parents=True, exist_ok=True)
# Act
result = subprocess.run(
[
cmake,
"-S",
str(REPO_ROOT),
"-B",
str(build_dir),
"-DBUILD_TESTING=OFF",
],
capture_output=True,
text=True,
check=False,
)
# Assert
assert result.returncode == 0, (
f"cmake configure failed:\nstdout:\n{result.stdout}\nstderr:\n{result.stderr}"
)