release: bump version to 0.52.0
This commit is contained in:
44
backend/tests/test_layers.py
Normal file
44
backend/tests/test_layers.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from fastapi import HTTPException
|
||||
|
||||
from app.api.v1 import layers
|
||||
|
||||
|
||||
def test_layer_guard_requires_bbox():
|
||||
try:
|
||||
layers._parse_layer_bbox("")
|
||||
except HTTPException as exc:
|
||||
assert exc.status_code == 400
|
||||
else:
|
||||
raise AssertionError("Expected missing bbox to fail")
|
||||
|
||||
|
||||
def test_layer_guard_filters_bbox_and_clamps_low_zoom_limit():
|
||||
geojson = {
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {"type": "Point", "coordinates": [121.0, 31.0]},
|
||||
"properties": {"id": "inside"},
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {"type": "Point", "coordinates": [10.0, 10.0]},
|
||||
"properties": {"id": "outside"},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
result = layers._guard_geojson_layer(
|
||||
geojson,
|
||||
bbox=(120.0, 30.0, 122.0, 32.0),
|
||||
zoom=2,
|
||||
limit=6000,
|
||||
)
|
||||
|
||||
assert result["returned_count"] == 1
|
||||
assert result["visible_count"] == 1
|
||||
assert result["features"][0]["properties"]["id"] == "inside"
|
||||
assert result["diagnostics"]["limit"] == layers.LOW_ZOOM_FEATURE_LIMIT
|
||||
assert result["diagnostics"]["limit_clamped"] is True
|
||||
assert result["diagnostics"]["degraded"] is True
|
||||
Reference in New Issue
Block a user