Respect VMM flood coverage size limit
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-15 22:23:22 +02:00
parent 501f824257
commit 943ecfbc90
2 changed files with 51 additions and 2 deletions
@@ -137,6 +137,35 @@ def test_flood_hazard_request_is_bounded_and_rejects_arbitrary_products() -> Non
assert exc_info.value.code == "FLOOD_HAZARD_PRODUCT_NOT_SUPPORTED"
def test_flood_hazard_tiles_stay_below_the_observed_vmm_coverage_limit() -> None:
prepared = FloodHazardAcquisitionService._prepared_request(flood_payload(side_m=15_000), Settings(_env_file=None))
tiles = FloodHazardAcquisitionService._tile_bounds(prepared)
assert 9 <= len(tiles) <= 16
assert all((max_x - min_x) <= 5_000 for min_x, _min_y, max_x, _max_y in tiles)
assert all((max_y - min_y) <= 5_000 for _min_x, min_y, _max_x, max_y in tiles)
assert all(
((max_x - min_x) / prepared["resolution_m"]) * ((max_y - min_y) / prepared["resolution_m"])
<= 1_000_000
for min_x, min_y, max_x, max_y in tiles
)
def test_flood_hazard_xml_provider_error_is_exposed_without_losing_the_canonical_error() -> None:
response = b"""<?xml version="1.0"?>
<ExceptionReport xmlns="http://www.opengis.net/ows/1.1">
<Exception exceptionCode="NoApplicableCode">
<ExceptionText>This request is trying to generate too much data</ExceptionText>
</Exception>
</ExceptionReport>"""
with pytest.raises(AppError) as exc_info:
FloodHazardAcquisitionService._extract_geotiff(response, "application/xml")
assert exc_info.value.code == "FLOOD_HAZARD_PROVIDER_INVALID_RESPONSE"
assert exc_info.value.details["provider_exception"] == "This request is trying to generate too much data"
def test_flood_hazard_normalization_converts_centimetres_and_clips_zero_values() -> None:
payload = flood_payload()
prepared = FloodHazardAcquisitionService._prepared_request(payload, Settings(_env_file=None))