Files
geointel/tests/test_provision_belgium_building_training_portfolio.py
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

94 lines
2.8 KiB
Python

import json
from pathlib import Path
import pytest
from scripts.provision_belgium_building_training_portfolio import AOIS, load_custom_aois
V63_CANDIDATES = {
"aarschot-mixed-cal-candidate-v63",
"beveren-ribbon-cal-candidate-v63",
"oostkamp-suburban-cal-candidate-v63",
}
V66_CANDIDATES = {
"zutendaal-lowrise-cal-candidate-v66",
"zoersel-lowrise-cal-candidate-v66",
"landen-rural-cal-candidate-v66",
}
def test_portfolio_slugs_are_unique() -> None:
slugs = [aoi.slug for aoi in AOIS]
assert len(slugs) == len(set(slugs))
def test_v63_calibration_candidates_are_flemish_train_role_inputs() -> None:
candidates = {aoi.slug: aoi for aoi in AOIS if aoi.slug in V63_CANDIDATES}
assert set(candidates) == V63_CANDIDATES
assert all(aoi.region == "flanders" for aoi in candidates.values())
assert all(aoi.split == "train" for aoi in candidates.values())
assert all(aoi.sample_role == "positive" for aoi in candidates.values())
def test_v66_lowrise_candidates_are_flemish_train_role_inputs() -> None:
candidates = {aoi.slug: aoi for aoi in AOIS if aoi.slug in V66_CANDIDATES}
assert set(candidates) == V66_CANDIDATES
assert all(aoi.region == "flanders" for aoi in candidates.values())
assert all(aoi.split == "train" for aoi in candidates.values())
assert all("lowrise" in aoi.context for aoi in candidates.values())
def test_custom_aoi_spec_loads_non_protected_calibration(tmp_path: Path) -> None:
spec = tmp_path / "aois.json"
spec.write_text(
json.dumps(
{
"aois": [
{
"slug": "fresh-rural-cal",
"region": "wallonia",
"context": "rural-lowrise",
"split": "calibration",
"lon": 5.25,
"lat": 50.25,
}
]
}
),
encoding="utf-8",
)
result = load_custom_aois(spec)
assert len(result) == 1
assert result[0].slug == "fresh-rural-cal"
assert result[0].split == "calibration"
@pytest.mark.parametrize("split", ["test", "background-test"])
def test_custom_aoi_spec_rejects_protected_splits(
tmp_path: Path, split: str
) -> None:
spec = tmp_path / "aois.json"
spec.write_text(
json.dumps(
{
"aois": [
{
"slug": "forbidden",
"region": "flanders",
"context": "urban",
"split": split,
"lon": 4.5,
"lat": 51.0,
}
]
}
),
encoding="utf-8",
)
with pytest.raises(SystemExit, match="protected/unsupported split"):
load_custom_aois(spec)