0001-map-don-t-fail-on-invalid-geojson-data-53521.patch
combo/apps/maps/models.py | ||
---|---|---|
227 | 227 |
) |
228 | 228 |
if not response.ok: |
229 | 229 |
return [] |
230 |
data = response.json() |
|
230 |
try: |
|
231 |
data = response.json() |
|
232 |
except json.JSONDecodeError: |
|
233 |
return [] |
|
231 | 234 |
if 'features' in data: |
232 | 235 |
features = data['features'] |
233 | 236 |
else: |
tests/test_maps_cells.py | ||
---|---|---|
7 | 7 |
from django.contrib.auth.models import Group, User |
8 | 8 |
from django.test.client import RequestFactory |
9 | 9 |
from django.urls import reverse |
10 |
from requests.models import Response |
|
10 | 11 | |
11 | 12 |
from combo.apps.maps.models import Map, MapLayer, MapLayerOptions |
12 | 13 |
from combo.data.models import Page |
... | ... | |
284 | 285 | |
285 | 286 |
geojson_url = reverse('mapcell-geojson', kwargs={'cell_id': cell.id, 'layer_slug': layer.slug}) |
286 | 287 | |
288 |
# invalid content |
|
289 |
with mock.patch('combo.utils.requests_wrapper.RequestsSession.get') as requests_get: |
|
290 |
mock_resp = Response() |
|
291 |
mock_resp.status_code = 300 |
|
292 |
requests_get.return_value = mock_resp |
|
293 |
resp = app.get(geojson_url) |
|
294 |
assert resp.json == [] |
|
295 | ||
287 | 296 |
# check cache duration |
288 | 297 |
with mock.patch('combo.utils.requests_wrapper.RequestsSession.request') as requests_get: |
289 | 298 |
requests_get.return_value = mock.Mock( |
290 |
- |