Files
gps-denied-onboard/tests/unit/test_ac1_scaffold_layout.py
T
Oleksandr Bezdieniezhnykh b12db61444 [AZ-263] Bootstrap: repo skeleton + Docker + CI + Alembic + Tier-1 tests
Implements the AZ-263 / E-BOOT initial structure task:

- Python src/-layout package `gps_denied_onboard/` with per-component
  interface stubs (14 components), type-only DTOs under `_types/`,
  shared helpers under `helpers/` (R14 LightGlue ownership), structured
  JSON logging, runtime composition root with env-var fail-fast gate,
  healthcheck module shared by Docker and CI smoke.
- CMake top-level + `cmake/{build_options,dependencies,strategies}.cmake`
  with the BUILD_* per-binary flags (ADR-002) and pinned external git
  refs for OKVIS2 / VINS-Mono / GTSAM / FAISS / OpenCV >=4.12.0.
- Three Dockerfiles (companion-tier1, operator-tooling,
  mock-suite-sat-service) + two compose files (dev + Tier-1 test).
- Four GitHub Actions workflows: ci.yml (lint/unit/integration/dual
  binary build/SBOM diff/security), ci-tier2.yml (self-hosted Jetson
  AC-bound NFTs), release.yml, cve-rescan.yml.
- Two CI gate scripts: `ci/sbom_diff.py` (deployment SBOM subset +
  R02 exclusion), `ci/opencv_pin_gate.py` (>=4.12.0 enforcement,
  D-CROSS-CVE-1).
- Alembic-driven Postgres 16 initial migration `0001_initial.py`
  mirroring satellite-provider tiles + flights + sector_classifications
  + manifests + engine_cache_entries (data_model.md s 2).
- Tier-1 test scaffolding: 95 passing unit tests covering every AC,
  per-component smoke tests, structured logging JSON output check,
  env-var gate check, healthcheck import check. Two CI-gated tests
  (cmake configure, actionlint) skip locally with explicit reasons.
- Batch report + code review report under `_docs/03_implementation/`.

Verdict: PASS_WITH_WARNINGS (two Low findings, both informational).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 01:00:28 +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-tooling.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.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_tooling",
"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}"
)