Add bounded Flanders thematic analysis
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-17 18:28:48 +02:00
parent 21103441cf
commit ce597ee0b4
17 changed files with 389 additions and 55 deletions
@@ -21,7 +21,9 @@ def test_evolution_mode_falls_back_to_an_available_series() -> None:
def test_evolution_theme_catalog_distinguishes_history_from_current_only_data() -> None:
workspace = read("frontend/src/components/map/MapWorkspace.tsx")
assert "analysisMode === 'current' || evolutionAvailable" in workspace
assert "analysisMode === 'current'" in workspace
assert "Boolean(dataset || onDemandProduct)" in workspace
assert "Boolean(dataset) && evolutionAvailable" in workspace
assert "meetmomenten" in workspace
assert "Tijdreeks" in workspace
assert "Alleen huidige toestand" in workspace
@@ -17,7 +17,7 @@ from app.core.config import Settings
from app.core.errors import AppError
from app.db.session import get_db
from app.main import app
from app.models import Dataset, Job, Project
from app.models import Area, Dataset, Job, Project
from app.schemas.thematic_raster import ThematicRasterAcquireRequest, ThematicRasterSelectionRequest
from app.schemas.assistant import AssistantQueryRequest
from app.services.geo_assistant_service import GeoAssistantService
@@ -177,6 +177,20 @@ def test_complete_kempen_scope_fits_the_tiled_thematic_guardrails() -> None:
assert exc_info.value.code == "THEMATIC_RASTER_SELECTION_TOO_LARGE"
def test_coverage_scope_only_labels_named_municipality_areas_as_municipality() -> None:
project_id = uuid4()
municipality_id = uuid4()
region_id = uuid4()
db = FakeSession({
(Area, municipality_id): Area(id=municipality_id, project_id=project_id, name="Gemeente Mol"),
(Area, region_id): Area(id=region_id, project_id=project_id, name="Vlaanderen"),
})
assert ThematicRasterAcquisitionService._coverage_scope(db, municipality_id) == "municipality"
assert ThematicRasterAcquisitionService._coverage_scope(db, region_id) == "bounded_selection"
assert ThematicRasterAcquisitionService._coverage_scope(db, None) == "bounded_selection"
def test_wcs_fetch_retries_an_incomplete_tile_without_accepting_partial_bytes(monkeypatch) -> None:
content = b"II*\x00complete-geotiff"
responses = [IncompleteResponse(content), FakeResponse(content)]
@@ -339,7 +339,8 @@ def test_theme_failures_name_the_source_and_reason() -> None:
root = Path(__file__).resolve().parents[2]
hook = (root / "frontend/src/hooks/useMapThemeSelectionInsights.ts").read_text(encoding="utf-8")
assert "dataset: queries[index]?.dataset.name" in hook
assert "queries[index]?.dataset?.name" in hook
assert "queries[index]?.thematicProductKey" in hook
assert "reason: formatError(item.reason" in hook
assert "failure.dataset}: ${failure.reason}" in hook
@@ -0,0 +1,59 @@
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def read(path: str) -> str:
return (ROOT / path).read_text(encoding="utf-8")
def test_flanders_workspace_exposes_governed_thematic_products_on_demand() -> None:
workspace = read("frontend/src/components/map/MapWorkspace.tsx")
product_hook = read("frontend/src/hooks/useThematicRasterProducts.ts")
selection_hook = read("frontend/src/hooks/useMapThemeSelectionInsights.ts")
api = read("frontend/src/services/api/datasets.ts")
assert "activeScopeProject?.name === FLANDERS_WORKSPACE_PROJECT_NAME" in workspace
assert "new Map<DataThemeId, ThematicRasterProductRead>" in workspace
assert "'Op aanvraag'" in workspace
assert "thematicProductKey: thematicProduct.key" in workspace
assert "datasetsApi.listThematicRasterProducts" in product_hook
assert "datasetsApi.acquireThematicRaster" in selection_hook
assert "datasetsApi.selectThematicRaster" in selection_hook
assert "datasetsApi.get(selectedProjectId, acquisition.output_dataset_id)" in selection_hook
assert "/datasets/thematic-raster/acquire" in api
def test_selection_runs_all_available_themes_and_refreshes_persisted_datasets() -> None:
workspace = read("frontend/src/components/map/MapWorkspace.tsx")
app = read("frontend/src/App.tsx")
selection_hook = read("frontend/src/hooks/useMapThemeSelectionInsights.ts")
assert "for (const theme of DATA_THEMES)" in workspace
assert "await loadThemeInsights(bbox, availableThemes, areaId)" in workspace
assert "!regionalPartitionedThemeActive && !onDemandThematicThemeActive" in workspace
assert "onRefreshProjectData" in workspace
assert "selectedProjectId ? loadProjectData(selectedProjectId)" in app
assert "successful.some((item) => item.thematicProductKey)" in selection_hook
assert "await onDatasetsChanged()" in selection_hook
def test_regional_on_demand_rasters_require_a_bounded_drawn_selection() -> None:
workspace = read("frontend/src/components/map/MapWorkspace.tsx")
assert "regionalOnDemandThematicThemeActive" in workspace
assert "regionalRasterThemeActive || regionalOnDemandThematicThemeActive" in workspace
assert "Teken een begrensde rechthoek voor een regionale rasteranalyse." in workspace
assert "officiële Vlaamse rasters worden begrensd opgehaald, bewaard en hergebruikt" in workspace
def test_frontend_does_not_contact_the_external_wcs_directly() -> None:
frontend_sources = "\n".join(
path.read_text(encoding="utf-8")
for path in (ROOT / "frontend/src").rglob("*")
if path.suffix in {".ts", ".tsx"}
)
assert "mercatornet.be" not in frontend_sources.casefold()
assert "GetCoverage" not in frontend_sources