Projet

Général

Profil

0001-maps-handle-empty-geojson-58283.patch

Valentin Deniaud, 02 novembre 2021 12:05

Télécharger (1,6 ko)

Voir les différences:

Subject: [PATCH] maps: handle empty geojson (#58283)

 combo/apps/maps/models.py | 6 ++++++
 tests/test_maps_cells.py  | 5 +++++
 2 files changed, 11 insertions(+)
combo/apps/maps/models.py
241 241
                'features': [],
242 242
                '_combo_err_desc': "Non JSON response from requested URL",
243 243
            }
244
        if data is None:
245
            return {
246
                'type': 'FeatureCollection',
247
                'features': [],
248
                '_combo_err_desc': "Empty JSON response",
249
            }
244 250
        if 'features' in data:
245 251
            features = data['features']
246 252
        else:
tests/test_maps_cells.py
304 304
        assert len(resp.json['features']) == 0
305 305
        assert resp.json['_combo_err_desc'] == 'Non JSON response from requested URL'
306 306

  
307
        mock_resp.json = lambda: None
308
        resp = app.get(geojson_url)
309
        assert len(resp.json['features']) == 0
310
        assert resp.json['_combo_err_desc'] == 'Empty JSON response'
311

  
307 312
        mock_resp.status_code = 500
308 313
        resp = app.get(geojson_url)
309 314
        assert len(resp.json['features']) == 0
310
-