22 |
22 |
"type": "Feature",
|
23 |
23 |
"properties": {
|
24 |
24 |
"name": "Foo",
|
25 |
|
"extra": "Baz"
|
|
25 |
"extra": "Baz",
|
|
26 |
"color": "#0a0a0a",
|
|
27 |
"subcolor": {
|
|
28 |
"color": "#0a0a0a"
|
|
29 |
}
|
26 |
30 |
},
|
27 |
31 |
"geometry": {
|
28 |
32 |
"type": "Point",
|
... | ... | |
105 |
109 |
layer = MapLayer()
|
106 |
110 |
layer.label = 'bicycles'
|
107 |
111 |
layer.geojson_url = 'http://example.org/geojson'
|
108 |
|
layer.marker_colour = 'FF0000'
|
|
112 |
layer.marker_colour = '#FF0000'
|
109 |
113 |
layer.icon = 'fa-bicycle'
|
110 |
|
layer.icon_colour = '0000FF'
|
|
114 |
layer.icon_colour = '#0000FF'
|
111 |
115 |
layer.save()
|
112 |
116 |
return layer
|
113 |
117 |
|
... | ... | |
606 |
610 |
assert 'name' in features[0]['properties']
|
607 |
611 |
assert 'extra' not in features[0]['properties']
|
608 |
612 |
|
|
613 |
with mock.patch('combo.utils.requests_wrapper.RequestsSession.request') as requests_get:
|
|
614 |
layer.geojson_url = 'http://example.org/geojson?t2'
|
|
615 |
layer.properties = 'name, hop'
|
|
616 |
layer.marker_colour = 'color'
|
|
617 |
layer.save()
|
|
618 |
requests_get.return_value = mock.Mock(
|
|
619 |
content=SAMPLE_GEOJSON_CONTENT, json=lambda: json.loads(SAMPLE_GEOJSON_CONTENT), status_code=200
|
|
620 |
)
|
|
621 |
resp = app.get(reverse('mapcell-geojson', kwargs={'cell_id': cell.id, 'layer_slug': layer.slug}))
|
|
622 |
features = json.loads(resp.text)['features']
|
|
623 |
assert 'name' in features[0]['properties']
|
|
624 |
assert 'extra' not in features[0]['properties']
|
|
625 |
assert 'color' in features[0]['properties']
|
|
626 |
|
|
627 |
with mock.patch('combo.utils.requests_wrapper.RequestsSession.request') as requests_get:
|
|
628 |
layer.geojson_url = 'http://example.org/geojson?t2'
|
|
629 |
layer.properties = 'name, hop'
|
|
630 |
layer.marker_colour = 'subcolor.color'
|
|
631 |
layer.save()
|
|
632 |
requests_get.return_value = mock.Mock(
|
|
633 |
content=SAMPLE_GEOJSON_CONTENT, json=lambda: json.loads(SAMPLE_GEOJSON_CONTENT), status_code=200
|
|
634 |
)
|
|
635 |
resp = app.get(reverse('mapcell-geojson', kwargs={'cell_id': cell.id, 'layer_slug': layer.slug}))
|
|
636 |
features = json.loads(resp.text)['features']
|
|
637 |
assert 'name' in features[0]['properties']
|
|
638 |
assert 'extra' not in features[0]['properties']
|
|
639 |
assert 'subcolor' in features[0]['properties']
|
|
640 |
assert 'color' in features[0]['properties']['subcolor']
|
|
641 |
|
609 |
642 |
with mock.patch('combo.utils.requests_wrapper.RequestsSession.request') as requests_get:
|
610 |
643 |
layer.geojson_url = 'http://example.org/geojson?t3'
|
611 |
644 |
layer.properties = ''
|
612 |
|
-
|