Fix regional flood area pagination
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-16 01:34:12 +02:00
parent c018ed6dbb
commit ae82edf612
2 changed files with 24 additions and 8 deletions
@@ -42,9 +42,11 @@ class FakeSession:
def __init__(self, module):
self.module = module
self.posts: list[tuple[str, dict[str, Any]]] = []
self.gets: list[tuple[str, dict[str, Any]]] = []
self.headers: dict[str, str] = {}
def get(self, url: str, **_kwargs):
def get(self, url: str, **kwargs):
self.gets.append((url, kwargs.get("params") or {}))
if url.endswith("/api/v1/projects"):
return FakeResponse({"data": {"items": [{"id": "project-1", "name": "Kempen Regional Workbench"}]}})
if url.endswith("/areas"):
@@ -67,7 +69,10 @@ class FakeSession:
},
}
]
}
},
"total": 1,
"limit": kwargs.get("params", {}).get("limit", 50),
"offset": kwargs.get("params", {}).get("offset", 0),
}
)
if url.endswith("/datasets/flood-hazard/products"):
@@ -137,6 +142,7 @@ def test_regional_flood_operator_dry_run_uses_canonical_registry(monkeypatch, ca
assert '"status": "dry_run"' in output
assert '"planned_acquisitions": 1' in output
assert fake_session.posts == []
assert any(params.get("limit") == 200 for url, params in fake_session.gets if url.endswith("/areas"))
def test_regional_flood_operator_calls_acquisition_and_selection(monkeypatch, capsys) -> None:
+16 -6
View File
@@ -131,13 +131,23 @@ def resolve_areas(
project_id: str,
members: Sequence[ScopeMember],
) -> list[ResolvedArea]:
areas = unwrap(
session.get(
f"{base_url}/api/v1/projects/{project_id}/areas",
params={"limit": 500, "offset": 0},
timeout=60,
areas: list[dict[str, Any]] = []
limit = 200
offset = 0
while True:
page = unwrap(
session.get(
f"{base_url}/api/v1/projects/{project_id}/areas",
params={"limit": limit, "offset": offset},
timeout=60,
)
)
)["items"]
page_items = list(page["items"])
areas.extend(page_items)
total = int(page.get("total", len(areas)))
if len(areas) >= total or len(page_items) < limit:
break
offset += limit
resolved: list[ResolvedArea] = []
missing: list[str] = []
for member in members: