Files
geointel/backend/tests/test_rc8_release_journey_contract.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

75 lines
2.7 KiB
Python

from __future__ import annotations
import importlib.util
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
SCRIPT_PATH = ROOT / "scripts" / "provision_release_golden_areas.py"
def load_operator():
spec = importlib.util.spec_from_file_location("provision_release_golden_areas_test", SCRIPT_PATH)
assert spec and spec.loader
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def test_release_golden_area_contract_covers_belgium_and_north_sea() -> None:
module = load_operator()
created_keys = {item["key"] for item in module.GOLDEN_AREAS}
source_keys = {item["key"] for item in module.SOURCE_AREAS}
assert created_keys == {
"wallonia_urban_rural",
"brussels_urban",
"language_boundary",
"coast_land_sea",
"north_sea_multi_zone",
}
assert source_keys == {"mol_municipality", "kempen_region"}
assert len(created_keys | source_keys) == 7
assert all(item["source_project"] != module.NATIONAL_PROJECT for item in module.SOURCE_AREAS)
expected_zones = {
zone
for definition in (*module.GOLDEN_AREAS, *module.SOURCE_AREAS)
for zone in definition["expected_zones"]
}
assert {
"flanders",
"wallonia",
"brussels",
"territorial_sea",
"exclusive_economic_zone",
"continental_shelf",
} <= expected_zones
def test_release_golden_area_geometries_are_bounded_and_fingerprintable() -> None:
module = load_operator()
hashes = set()
for definition in module.GOLDEN_AREAS:
bbox = module.geometry_bbox(definition["geometry"])
assert -180 <= bbox["minx"] < bbox["maxx"] <= 180
assert -90 <= bbox["miny"] < bbox["maxy"] <= 90
assert bbox["maxx"] - bbox["minx"] <= 0.25
assert bbox["maxy"] - bbox["miny"] <= 0.20
digest = module.canonical_hash(definition["geometry"])
assert len(digest) == 64
hashes.add(digest)
assert len(hashes) == len(module.GOLDEN_AREAS)
def test_rc8_runner_and_container_operator_are_release_wired() -> None:
readiness = (ROOT / "scripts" / "run_readiness_check.sh").read_text(encoding="utf-8")
dockerfile = (ROOT / "deploy" / "unraid" / "Dockerfile.all-in-one").read_text(encoding="utf-8")
package = (ROOT / "frontend" / "package.json").read_text(encoding="utf-8")
assert "npm run test:unit" in readiness
assert '--check frontend/e2e/releaseJourneys.mjs' in readiness
assert "bash -n scripts/run_rc8_release_journeys.sh" in readiness
assert "COPY scripts/provision_release_golden_areas.py" in dockerfile
assert '"test:e2e": "node e2e/releaseJourneys.mjs"' in package