Files
geointel/backend/tests/test_belgium_training_portfolio.py
T
Jens e607cbe724
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s
Add fail-closed Belgian training loop
2026-07-27 02:29:14 +02:00

35 lines
1.3 KiB
Python

from __future__ import annotations
import importlib.util
import sys
from collections import Counter
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
SPEC = importlib.util.spec_from_file_location(
"building_portfolio", ROOT / "scripts" / "provision_belgium_building_training_portfolio.py"
)
assert SPEC and SPEC.loader
module = importlib.util.module_from_spec(SPEC)
sys.modules[SPEC.name] = module
SPEC.loader.exec_module(module)
def test_portfolio_covers_every_region_split_and_context_family() -> None:
assert len({aoi.slug for aoi in module.AOIS}) == len(module.AOIS)
counts = Counter((aoi.region, aoi.split) for aoi in module.AOIS)
for region in module.REGION_CONTRACT:
assert counts[(region, "train")] >= 10
assert counts[(region, "val")] >= 2
assert counts[(region, "calibration")] >= 3
assert counts[(region, "test")] >= 3
assert counts[(region, "background-test")] >= 2
def test_portfolio_bbox_is_metric_sized() -> None:
bbox = module.bbox_for_center(4.35, 50.85, 256.0)
to_metric = module.Transformer.from_crs("EPSG:4326", "EPSG:31370", always_xy=True)
bounds = to_metric.transform_bounds(bbox["min_x"], bbox["min_y"], bbox["max_x"], bbox["max_y"])
assert 255 <= bounds[2] - bounds[0] <= 258
assert 255 <= bounds[3] - bounds[1] <= 258