Files
geointel/scripts/validate_fixtures.py
T
Jens faeb58ef6d
GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
Initial public release
2026-08-31 21:56:53 +02:00

39 lines
1.4 KiB
Python

from pathlib import Path
import json
ROOT = Path(__file__).resolve().parents[1]
def _validate_feature_collection(path: Path) -> None:
data = json.loads(path.read_text(encoding="utf-8"))
if data.get("type") != "FeatureCollection":
raise SystemExit(f"{path} is not a FeatureCollection")
features = data.get("features")
if not isinstance(features, list):
raise SystemExit(f"{path} has no feature list")
for index, feature in enumerate(features):
geometry = feature.get("geometry") if isinstance(feature, dict) else None
if not isinstance(geometry, dict) or not geometry.get("type"):
raise SystemExit(f"{path} feature {index} has no geometry")
def _validate_fixture_dir(relative_path: str) -> None:
fixture_dir = ROOT / relative_path
if not fixture_dir.exists():
raise SystemExit(f"{relative_path} missing")
for path in fixture_dir.glob("*.geojson"):
_validate_feature_collection(path)
_validate_fixture_dir("fixtures/geojson")
_validate_fixture_dir("fixtures/golden")
expected_path = ROOT / "fixtures" / "golden" / "expected_qa_metrics.json"
expected = json.loads(expected_path.read_text(encoding="utf-8"))
for key in ("candidate_fixture", "reference_fixture"):
fixture_path = ROOT / expected[key]
if not fixture_path.exists():
raise SystemExit(f"Golden QA fixture missing: {fixture_path}")
print("Fixture validation OK")