100 |
100 |
layer = MapLayer.objects.get()
|
101 |
101 |
except MapLayer.DoesNotExist:
|
102 |
102 |
layer = MapLayer()
|
|
103 |
layer.label = 'bicycles'
|
103 |
104 |
layer.geojson_url = 'http://example.org/geojson'
|
104 |
105 |
layer.marker_colour = 'FF0000'
|
105 |
106 |
layer.icon = 'fa-bicycle'
|
... | ... | |
257 |
258 |
assert 'orig=combo' in requests_get.call_args[0][1]
|
258 |
259 |
assert not 'email=admin%40localhost&' in requests_get.call_args[0][1]
|
259 |
260 |
|
|
261 |
# query against layer name
|
|
262 |
resp = app.get(reverse('mapcell-geojson', kwargs={'cell_id': cell.id}) + '?q=bicycle')
|
|
263 |
assert len(json.loads(resp.content)['features']) == 0
|
|
264 |
|
260 |
265 |
# check distance query on geojson
|
261 |
266 |
layer.geojson_url = 'http://example.org/geojson?t6'
|
262 |
267 |
layer.include_user_identifier = False
|
... | ... | |
275 |
280 |
resp = app.get(reverse('mapcell-geojson', kwargs={'cell_id': cell.id}) + '?lng=2.54&lat=48.84&distance=100')
|
276 |
281 |
assert len(json.loads(resp.content)['features']) == 0
|
277 |
282 |
|
|
283 |
# add a second layer
|
|
284 |
layer2 = MapLayer()
|
|
285 |
layer2.label = 'xxx'
|
|
286 |
layer2.geojson_url = 'http://example.org/geojson'
|
|
287 |
layer2.marker_colour = 'FF0000'
|
|
288 |
layer2.icon = 'fa-bicycle'
|
|
289 |
layer2.icon_colour = '0000FF'
|
|
290 |
layer2.save()
|
|
291 |
cell.layers.add(layer2)
|
|
292 |
|
|
293 |
with mock.patch('combo.utils.requests_wrapper.RequestsSession.request') as requests_get:
|
|
294 |
requests_get.return_value = mock.Mock(
|
|
295 |
content=SAMPLE_GEOJSON_CONTENT,
|
|
296 |
json=lambda: json.loads(SAMPLE_GEOJSON_CONTENT),
|
|
297 |
status_code=200)
|
|
298 |
resp = app.get(reverse('mapcell-geojson', kwargs={'cell_id': cell.id}) + '?q=bar')
|
|
299 |
assert len(json.loads(resp.content)['features']) == 2
|
|
300 |
|
|
301 |
resp = app.get(reverse('mapcell-geojson', kwargs={'cell_id': cell.id}) + '?q=xyz')
|
|
302 |
assert len(json.loads(resp.content)['features']) == 0
|
|
303 |
|
|
304 |
# query against layer name, it should get results
|
|
305 |
resp = app.get(reverse('mapcell-geojson', kwargs={'cell_id': cell.id}) + '?q=bicycle')
|
|
306 |
assert len(json.loads(resp.content)['features']) == 2
|
|
307 |
|
|
308 |
|
278 |
309 |
def test_get_geojson_properties(app, layer, user):
|
279 |
310 |
page = Page(title='xxx', slug='new', template_name='standard')
|
280 |
311 |
page.save()
|
281 |
|
-
|