Add deterministic portfolio spec composition
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

This commit is contained in:
Jens
2026-07-30 03:01:47 +02:00
parent 797bfb5cda
commit f55668fb4b
2 changed files with 114 additions and 0 deletions
@@ -0,0 +1,38 @@
import json
from pathlib import Path
import pytest
from scripts.combine_belgium_building_portfolio_specs import combine_specs
def write_spec(path: Path, slug: str, *, resolution: float = 0.25, status: str = "complete") -> Path:
path.write_text(json.dumps({
"status": status,
"side_m": 256.0,
"resolution_m": resolution,
"samples": [{"sample_slug": slug}],
}), encoding="utf-8")
return path
def test_combine_specs_records_provenance(tmp_path: Path) -> None:
payload = combine_specs([write_spec(tmp_path / "one.json", "one"), write_spec(tmp_path / "two.json", "two")])
assert payload["sample_count"] == 2
assert [sample["sample_slug"] for sample in payload["samples"]] == ["one", "two"]
assert all(len(source["sha256"]) == 64 for source in payload["source_specs"])
def test_combine_specs_rejects_duplicate_slugs(tmp_path: Path) -> None:
with pytest.raises(ValueError, match="Duplicate"):
combine_specs([write_spec(tmp_path / "one.json", "same"), write_spec(tmp_path / "two.json", "same")])
def test_combine_specs_rejects_mismatched_resolution(tmp_path: Path) -> None:
with pytest.raises(ValueError, match="resolution"):
combine_specs([write_spec(tmp_path / "one.json", "one"), write_spec(tmp_path / "two.json", "two", resolution=0.5)])
def test_combine_specs_rejects_incomplete_source(tmp_path: Path) -> None:
with pytest.raises(ValueError, match="not complete"):
combine_specs([write_spec(tmp_path / "one.json", "one", status="in_progress")])