maps: handle empty geojson (#58283)
This commit is contained in:
parent
a3d180eee9
commit
a4b2cecd0f
|
@ -241,6 +241,12 @@ class MapLayer(models.Model):
|
||||||
'features': [],
|
'features': [],
|
||||||
'_combo_err_desc': "Non JSON response from requested URL",
|
'_combo_err_desc': "Non JSON response from requested URL",
|
||||||
}
|
}
|
||||||
|
if data is None:
|
||||||
|
return {
|
||||||
|
'type': 'FeatureCollection',
|
||||||
|
'features': [],
|
||||||
|
'_combo_err_desc': "Empty JSON response",
|
||||||
|
}
|
||||||
if 'features' in data:
|
if 'features' in data:
|
||||||
features = data['features']
|
features = data['features']
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -304,6 +304,11 @@ def test_get_geojson(app, layer, user):
|
||||||
assert len(resp.json['features']) == 0
|
assert len(resp.json['features']) == 0
|
||||||
assert resp.json['_combo_err_desc'] == 'Non JSON response from requested URL'
|
assert resp.json['_combo_err_desc'] == 'Non JSON response from requested URL'
|
||||||
|
|
||||||
|
mock_resp.json = lambda: None
|
||||||
|
resp = app.get(geojson_url)
|
||||||
|
assert len(resp.json['features']) == 0
|
||||||
|
assert resp.json['_combo_err_desc'] == 'Empty JSON response'
|
||||||
|
|
||||||
mock_resp.status_code = 500
|
mock_resp.status_code = 500
|
||||||
resp = app.get(geojson_url)
|
resp = app.get(geojson_url)
|
||||||
assert len(resp.json['features']) == 0
|
assert len(resp.json['features']) == 0
|
||||||
|
|
Loading…
Reference in New Issue