Respect VMM flood coverage size limit
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user