umap-project 2.1.2__py3-none-any.whl → 2.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/models.py +2 -0
- umap/static/umap/js/umap.controls.js +29 -0
- umap/static/umap/js/umap.features.js +3 -1
- umap/static/umap/js/umap.importer.js +4 -5
- umap/static/umap/js/umap.js +27 -36
- umap/static/umap/js/umap.layer.js +7 -6
- umap/static/umap/test/Map.js +0 -304
- umap/static/umap/test/Polygon.js +0 -256
- umap/static/umap/test/Polyline.js +0 -116
- umap/static/umap/test/index.html +1 -4
- umap/tests/conftest.py +9 -0
- umap/tests/fixtures/test_upload_data.csv +2 -1
- umap/tests/fixtures/test_upload_data.umap +171 -0
- umap/tests/fixtures/test_upload_data_osm.json +33 -0
- umap/tests/integration/conftest.py +5 -0
- umap/tests/integration/test_anonymous_owned_map.py +3 -0
- umap/tests/integration/test_browser.py +4 -11
- umap/tests/integration/test_choropleth.py +89 -0
- umap/tests/integration/test_collaborative_editing.py +30 -1
- umap/tests/integration/test_datalayer.py +130 -0
- umap/tests/integration/test_edit_datalayer.py +134 -0
- umap/tests/integration/test_edit_map.py +15 -0
- umap/tests/integration/test_facets_browser.py +31 -0
- umap/tests/integration/test_import.py +347 -2
- umap/tests/integration/test_map.py +17 -37
- umap/tests/integration/test_owned_map.py +18 -0
- umap/tests/integration/test_picto.py +20 -33
- umap/tests/integration/test_polygon.py +363 -0
- umap/tests/integration/test_polyline.py +325 -0
- umap/tests/integration/test_tableeditor.py +27 -0
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/METADATA +4 -4
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/RECORD +36 -33
- umap/static/umap/test/Choropleth.js +0 -245
- umap/static/umap/test/DataLayer.js +0 -463
- umap/static/umap/test/Permissions.js +0 -74
- umap/static/umap/test/TableEditor.js +0 -104
- umap/tests/integration/test_drawing.py +0 -243
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/WHEEL +0 -0
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/entry_points.txt +0 -0
- {umap_project-2.1.2.dist-info → umap_project-2.1.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import re
|
|
1
3
|
from pathlib import Path
|
|
2
4
|
|
|
3
5
|
import pytest
|
|
4
6
|
from playwright.sync_api import expect
|
|
5
7
|
|
|
8
|
+
from umap.models import DataLayer
|
|
9
|
+
|
|
6
10
|
pytestmark = pytest.mark.django_db
|
|
7
11
|
|
|
8
12
|
|
|
9
|
-
def test_umap_import_from_file(live_server,
|
|
13
|
+
def test_umap_import_from_file(live_server, tilelayer, page):
|
|
10
14
|
page.goto(f"{live_server.url}/map/new/")
|
|
11
15
|
button = page.get_by_title("Import data")
|
|
12
16
|
expect(button).to_be_visible()
|
|
@@ -28,9 +32,40 @@ def test_umap_import_from_file(live_server, datalayer, page):
|
|
|
28
32
|
# Close the import panel
|
|
29
33
|
page.keyboard.press("Escape")
|
|
30
34
|
assert not file_input.input_value()
|
|
35
|
+
expect(page.locator(".umap-main-edit-toolbox .map-name")).to_have_text(
|
|
36
|
+
"Carte sans nom"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_umap_import_from_textarea(live_server, tilelayer, page, settings):
|
|
41
|
+
settings.UMAP_ALLOW_ANONYMOUS = True
|
|
42
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
43
|
+
page.get_by_title("Import data").click()
|
|
44
|
+
textarea = page.locator(".umap-upload textarea")
|
|
45
|
+
path = Path(__file__).parent.parent / "fixtures/test_upload_data.umap"
|
|
46
|
+
textarea.fill(path.read_text())
|
|
47
|
+
page.locator('select[name="format"]').select_option("umap")
|
|
48
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
49
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
50
|
+
expect(layers).to_have_count(2)
|
|
51
|
+
expect(page.locator(".umap-main-edit-toolbox .map-name")).to_have_text(
|
|
52
|
+
"Imported map"
|
|
53
|
+
)
|
|
54
|
+
page.get_by_role("button", name="See data layers").click()
|
|
55
|
+
expect(page.get_by_text("Tunnels")).to_be_visible()
|
|
56
|
+
expect(page.get_by_text("Cities")).to_be_visible()
|
|
57
|
+
expect(page.locator(".leaflet-control-minimap")).to_be_visible()
|
|
58
|
+
expect(
|
|
59
|
+
page.locator('img[src="https://tile.openstreetmap.fr/hot/6/32/21.png"]')
|
|
60
|
+
).to_be_visible()
|
|
61
|
+
# Should not have imported umap_id, while in the file options
|
|
62
|
+
assert not page.evaluate("U.MAP.options.umap_id")
|
|
63
|
+
with page.expect_response(re.compile(r".*/datalayer/create/.*")):
|
|
64
|
+
page.get_by_role("button", name="Save").click()
|
|
65
|
+
assert page.evaluate("U.MAP.options.umap_id")
|
|
31
66
|
|
|
32
67
|
|
|
33
|
-
def
|
|
68
|
+
def test_import_geojson_from_textarea(tilelayer, live_server, page):
|
|
34
69
|
page.goto(f"{live_server.url}/map/new/")
|
|
35
70
|
layers = page.locator(".umap-browse-datalayers li")
|
|
36
71
|
markers = page.locator(".leaflet-marker-icon")
|
|
@@ -52,3 +87,313 @@ def test_umap_import_geojson_from_textarea(live_server, datalayer, page):
|
|
|
52
87
|
expect(layers).to_have_count(1)
|
|
53
88
|
expect(markers).to_have_count(2)
|
|
54
89
|
expect(paths).to_have_count(3)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_import_kml_from_textarea(tilelayer, live_server, page):
|
|
93
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
94
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
95
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
96
|
+
paths = page.locator("path")
|
|
97
|
+
expect(markers).to_have_count(0)
|
|
98
|
+
expect(paths).to_have_count(0)
|
|
99
|
+
expect(layers).to_have_count(0)
|
|
100
|
+
button = page.get_by_title("Import data")
|
|
101
|
+
expect(button).to_be_visible()
|
|
102
|
+
button.click()
|
|
103
|
+
textarea = page.locator(".umap-upload textarea")
|
|
104
|
+
path = Path(__file__).parent.parent / "fixtures/test_upload_data.kml"
|
|
105
|
+
textarea.fill(path.read_text())
|
|
106
|
+
page.locator('select[name="format"]').select_option("kml")
|
|
107
|
+
button = page.get_by_role("button", name="Import", exact=True)
|
|
108
|
+
expect(button).to_be_visible()
|
|
109
|
+
button.click()
|
|
110
|
+
# A layer has been created
|
|
111
|
+
expect(layers).to_have_count(1)
|
|
112
|
+
expect(markers).to_have_count(1)
|
|
113
|
+
expect(paths).to_have_count(2)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_import_gpx_from_textarea(tilelayer, live_server, page):
|
|
117
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
118
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
119
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
120
|
+
paths = page.locator("path")
|
|
121
|
+
expect(markers).to_have_count(0)
|
|
122
|
+
expect(paths).to_have_count(0)
|
|
123
|
+
expect(layers).to_have_count(0)
|
|
124
|
+
button = page.get_by_title("Import data")
|
|
125
|
+
expect(button).to_be_visible()
|
|
126
|
+
button.click()
|
|
127
|
+
textarea = page.locator(".umap-upload textarea")
|
|
128
|
+
path = Path(__file__).parent.parent / "fixtures/test_upload_data.gpx"
|
|
129
|
+
textarea.fill(path.read_text())
|
|
130
|
+
page.locator('select[name="format"]').select_option("gpx")
|
|
131
|
+
button = page.get_by_role("button", name="Import", exact=True)
|
|
132
|
+
expect(button).to_be_visible()
|
|
133
|
+
button.click()
|
|
134
|
+
# A layer has been created
|
|
135
|
+
expect(layers).to_have_count(1)
|
|
136
|
+
expect(markers).to_have_count(1)
|
|
137
|
+
expect(paths).to_have_count(1)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def test_import_osm_from_textarea(tilelayer, live_server, page):
|
|
141
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
142
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
143
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
144
|
+
expect(markers).to_have_count(0)
|
|
145
|
+
expect(layers).to_have_count(0)
|
|
146
|
+
button = page.get_by_title("Import data")
|
|
147
|
+
expect(button).to_be_visible()
|
|
148
|
+
button.click()
|
|
149
|
+
textarea = page.locator(".umap-upload textarea")
|
|
150
|
+
path = Path(__file__).parent.parent / "fixtures/test_upload_data_osm.json"
|
|
151
|
+
textarea.fill(path.read_text())
|
|
152
|
+
page.locator('select[name="format"]').select_option("osm")
|
|
153
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
154
|
+
# A layer has been created
|
|
155
|
+
expect(layers).to_have_count(1)
|
|
156
|
+
expect(markers).to_have_count(2)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def test_import_csv_from_textarea(tilelayer, live_server, page):
|
|
160
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
161
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
162
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
163
|
+
expect(markers).to_have_count(0)
|
|
164
|
+
expect(layers).to_have_count(0)
|
|
165
|
+
button = page.get_by_title("Import data")
|
|
166
|
+
expect(button).to_be_visible()
|
|
167
|
+
button.click()
|
|
168
|
+
textarea = page.locator(".umap-upload textarea")
|
|
169
|
+
path = Path(__file__).parent.parent / "fixtures/test_upload_data.csv"
|
|
170
|
+
textarea.fill(path.read_text())
|
|
171
|
+
page.locator('select[name="format"]').select_option("csv")
|
|
172
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
173
|
+
# A layer has been created
|
|
174
|
+
expect(layers).to_have_count(1)
|
|
175
|
+
expect(markers).to_have_count(2)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def test_can_import_in_existing_datalayer(live_server, datalayer, page, openmap):
|
|
179
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
|
180
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
181
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
182
|
+
expect(markers).to_have_count(1)
|
|
183
|
+
expect(layers).to_have_count(1)
|
|
184
|
+
page.get_by_role("button", name="Edit").click()
|
|
185
|
+
page.get_by_title("Import data").click()
|
|
186
|
+
textarea = page.locator(".umap-upload textarea")
|
|
187
|
+
path = Path(__file__).parent.parent / "fixtures/test_upload_data.csv"
|
|
188
|
+
textarea.fill(path.read_text())
|
|
189
|
+
page.locator('select[name="format"]').select_option("csv")
|
|
190
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
191
|
+
# No layer has been created
|
|
192
|
+
expect(layers).to_have_count(1)
|
|
193
|
+
expect(markers).to_have_count(3)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def test_can_replace_datalayer_data(live_server, datalayer, page, openmap):
|
|
197
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
|
198
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
199
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
200
|
+
expect(markers).to_have_count(1)
|
|
201
|
+
expect(layers).to_have_count(1)
|
|
202
|
+
page.get_by_role("button", name="Edit").click()
|
|
203
|
+
page.get_by_title("Import data").click()
|
|
204
|
+
textarea = page.locator(".umap-upload textarea")
|
|
205
|
+
path = Path(__file__).parent.parent / "fixtures/test_upload_data.csv"
|
|
206
|
+
textarea.fill(path.read_text())
|
|
207
|
+
page.locator('select[name="format"]').select_option("csv")
|
|
208
|
+
page.get_by_label("Replace layer content").check()
|
|
209
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
210
|
+
# No layer has been created
|
|
211
|
+
expect(layers).to_have_count(1)
|
|
212
|
+
expect(markers).to_have_count(2)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def test_can_import_in_new_datalayer(live_server, datalayer, page, openmap):
|
|
216
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
|
217
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
218
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
219
|
+
expect(markers).to_have_count(1)
|
|
220
|
+
expect(layers).to_have_count(1)
|
|
221
|
+
page.get_by_role("button", name="Edit").click()
|
|
222
|
+
page.get_by_title("Import data").click()
|
|
223
|
+
textarea = page.locator(".umap-upload textarea")
|
|
224
|
+
path = Path(__file__).parent.parent / "fixtures/test_upload_data.csv"
|
|
225
|
+
textarea.fill(path.read_text())
|
|
226
|
+
page.locator('select[name="format"]').select_option("csv")
|
|
227
|
+
page.get_by_label("Choose the layer to import").select_option(
|
|
228
|
+
label="Import in a new layer"
|
|
229
|
+
)
|
|
230
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
231
|
+
# A new layer has been created
|
|
232
|
+
expect(layers).to_have_count(2)
|
|
233
|
+
expect(markers).to_have_count(3)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def test_should_remove_dot_in_property_names(live_server, page, settings, tilelayer):
|
|
237
|
+
settings.UMAP_ALLOW_ANONYMOUS = True
|
|
238
|
+
data = {
|
|
239
|
+
"type": "FeatureCollection",
|
|
240
|
+
"features": [
|
|
241
|
+
{
|
|
242
|
+
"geometry": {
|
|
243
|
+
"type": "Point",
|
|
244
|
+
"coordinates": [6.922931671142578, 47.481161607175736],
|
|
245
|
+
},
|
|
246
|
+
"type": "Feature",
|
|
247
|
+
"properties": {
|
|
248
|
+
"color": "",
|
|
249
|
+
"name": "Chez Rémy",
|
|
250
|
+
"A . in the name": "",
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"geometry": {
|
|
255
|
+
"type": "LineString",
|
|
256
|
+
"coordinates": [
|
|
257
|
+
[2.4609375, 48.88639177703194],
|
|
258
|
+
[2.48291015625, 48.76343113791796],
|
|
259
|
+
[2.164306640625, 48.719961222646276],
|
|
260
|
+
],
|
|
261
|
+
},
|
|
262
|
+
"type": "Feature",
|
|
263
|
+
"properties": {"color": "", "name": "Périf", "with a dot.": ""},
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
}
|
|
267
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
268
|
+
page.get_by_title("Import data").click()
|
|
269
|
+
textarea = page.locator(".umap-upload textarea")
|
|
270
|
+
textarea.fill(json.dumps(data))
|
|
271
|
+
page.locator('select[name="format"]').select_option("geojson")
|
|
272
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
273
|
+
with page.expect_response(re.compile(r".*/datalayer/create/.*")):
|
|
274
|
+
page.get_by_role("button", name="Save").click()
|
|
275
|
+
datalayer = DataLayer.objects.last()
|
|
276
|
+
saved_data = json.loads(Path(datalayer.geojson.path).read_text())
|
|
277
|
+
assert saved_data["features"][0]["properties"] == {
|
|
278
|
+
"color": "",
|
|
279
|
+
"name": "Chez Rémy",
|
|
280
|
+
"A _ in the name": "",
|
|
281
|
+
}
|
|
282
|
+
assert saved_data["features"][1]["properties"] == {
|
|
283
|
+
"color": "",
|
|
284
|
+
"name": "Périf",
|
|
285
|
+
"with a dot_": "",
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def test_import_geometry_collection(live_server, page, tilelayer):
|
|
290
|
+
data = {
|
|
291
|
+
"type": "GeometryCollection",
|
|
292
|
+
"geometries": [
|
|
293
|
+
{"type": "Point", "coordinates": [-80.6608, 35.0493]},
|
|
294
|
+
{
|
|
295
|
+
"type": "Polygon",
|
|
296
|
+
"coordinates": [
|
|
297
|
+
[
|
|
298
|
+
[-80.6645, 35.0449],
|
|
299
|
+
[-80.6634, 35.0460],
|
|
300
|
+
[-80.6625, 35.0455],
|
|
301
|
+
[-80.6638, 35.0442],
|
|
302
|
+
[-80.6645, 35.0449],
|
|
303
|
+
]
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"type": "LineString",
|
|
308
|
+
"coordinates": [
|
|
309
|
+
[-80.66237, 35.05950],
|
|
310
|
+
[-80.66269, 35.05926],
|
|
311
|
+
[-80.66284, 35.05893],
|
|
312
|
+
[-80.66308, 35.05833],
|
|
313
|
+
[-80.66385, 35.04387],
|
|
314
|
+
[-80.66303, 35.04371],
|
|
315
|
+
],
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
}
|
|
319
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
320
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
321
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
322
|
+
paths = page.locator("path")
|
|
323
|
+
expect(markers).to_have_count(0)
|
|
324
|
+
expect(paths).to_have_count(0)
|
|
325
|
+
expect(layers).to_have_count(0)
|
|
326
|
+
button = page.get_by_title("Import data")
|
|
327
|
+
expect(button).to_be_visible()
|
|
328
|
+
button.click()
|
|
329
|
+
textarea = page.locator(".umap-upload textarea")
|
|
330
|
+
textarea.fill(json.dumps(data))
|
|
331
|
+
page.locator('select[name="format"]').select_option("geojson")
|
|
332
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
333
|
+
# A layer has been created
|
|
334
|
+
expect(layers).to_have_count(1)
|
|
335
|
+
expect(markers).to_have_count(1)
|
|
336
|
+
expect(paths).to_have_count(2)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def test_import_multipolygon(live_server, page, tilelayer):
|
|
340
|
+
data = {
|
|
341
|
+
"type": "Feature",
|
|
342
|
+
"properties": {"name": "Some states"},
|
|
343
|
+
"geometry": {
|
|
344
|
+
"type": "MultiPolygon",
|
|
345
|
+
"coordinates": [
|
|
346
|
+
[
|
|
347
|
+
[[-109, 36], [-109, 40], [-102, 37], [-109, 36]],
|
|
348
|
+
[[-108, 39], [-107, 37], [-104, 37], [-108, 39]],
|
|
349
|
+
],
|
|
350
|
+
[[[-119, 42], [-120, 39], [-114, 41], [-119, 42]]],
|
|
351
|
+
],
|
|
352
|
+
},
|
|
353
|
+
}
|
|
354
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
355
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
356
|
+
paths = page.locator("path")
|
|
357
|
+
expect(paths).to_have_count(0)
|
|
358
|
+
expect(layers).to_have_count(0)
|
|
359
|
+
button = page.get_by_title("Import data")
|
|
360
|
+
expect(button).to_be_visible()
|
|
361
|
+
button.click()
|
|
362
|
+
textarea = page.locator(".umap-upload textarea")
|
|
363
|
+
textarea.fill(json.dumps(data))
|
|
364
|
+
page.locator('select[name="format"]').select_option("geojson")
|
|
365
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
366
|
+
# A layer has been created
|
|
367
|
+
expect(layers).to_have_count(1)
|
|
368
|
+
expect(paths).to_have_count(1)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def test_import_multipolyline(live_server, page, tilelayer):
|
|
372
|
+
data = {
|
|
373
|
+
"type": "FeatureCollection",
|
|
374
|
+
"features": [
|
|
375
|
+
{
|
|
376
|
+
"type": "Feature",
|
|
377
|
+
"properties": {},
|
|
378
|
+
"geometry": {
|
|
379
|
+
"type": "MultiLineString",
|
|
380
|
+
"coordinates": [[[-108, 46], [-113, 43]], [[-112, 45], [-115, 44]]],
|
|
381
|
+
},
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
}
|
|
385
|
+
page.goto(f"{live_server.url}/map/new/")
|
|
386
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
387
|
+
paths = page.locator("path")
|
|
388
|
+
expect(paths).to_have_count(0)
|
|
389
|
+
expect(layers).to_have_count(0)
|
|
390
|
+
button = page.get_by_title("Import data")
|
|
391
|
+
expect(button).to_be_visible()
|
|
392
|
+
button.click()
|
|
393
|
+
textarea = page.locator(".umap-upload textarea")
|
|
394
|
+
textarea.fill(json.dumps(data))
|
|
395
|
+
page.locator('select[name="format"]').select_option("geojson")
|
|
396
|
+
page.get_by_role("button", name="Import", exact=True).click()
|
|
397
|
+
# A layer has been created
|
|
398
|
+
expect(layers).to_have_count(1)
|
|
399
|
+
expect(paths).to_have_count(1)
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import json
|
|
2
1
|
import re
|
|
3
|
-
from pathlib import Path
|
|
4
2
|
|
|
5
3
|
import pytest
|
|
6
4
|
from playwright.sync_api import expect
|
|
7
5
|
|
|
8
|
-
from umap.models import Map
|
|
9
|
-
|
|
10
6
|
from ..base import DataLayerFactory
|
|
11
7
|
|
|
12
8
|
pytestmark = pytest.mark.django_db
|
|
@@ -150,19 +146,28 @@ def test_default_view_latest_with_polygon(map, live_server, page):
|
|
|
150
146
|
expect(layers).to_have_count(1)
|
|
151
147
|
|
|
152
148
|
|
|
149
|
+
def test_default_view_locate(browser, live_server, map):
|
|
150
|
+
context = browser.new_context(
|
|
151
|
+
geolocation={"longitude": 8.52967, "latitude": 39.16267},
|
|
152
|
+
permissions=["geolocation"],
|
|
153
|
+
)
|
|
154
|
+
map.settings["properties"]["defaultView"] = "locate"
|
|
155
|
+
map.save()
|
|
156
|
+
page = context.new_page()
|
|
157
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
158
|
+
expect(page).to_have_url(re.compile(r".*#18/39\.16267/8\.52967"))
|
|
159
|
+
|
|
160
|
+
|
|
153
161
|
def test_remote_layer_should_not_be_used_as_datalayer_for_created_features(
|
|
154
|
-
|
|
162
|
+
openmap, live_server, datalayer, page
|
|
155
163
|
):
|
|
156
|
-
# Faster than doing a login
|
|
157
|
-
map.edit_status = Map.ANONYMOUS
|
|
158
|
-
map.save()
|
|
159
164
|
datalayer.settings["remoteData"] = {
|
|
160
165
|
"url": "https://overpass-api.de/api/interpreter?data=[out:xml];node[harbour=yes]({south},{west},{north},{east});out body;",
|
|
161
166
|
"format": "osm",
|
|
162
167
|
"from": "10",
|
|
163
168
|
}
|
|
164
169
|
datalayer.save()
|
|
165
|
-
page.goto(f"{live_server.url}{
|
|
170
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
166
171
|
toggle = page.get_by_role("button", name="See data layers")
|
|
167
172
|
expect(toggle).to_be_visible()
|
|
168
173
|
toggle.click()
|
|
@@ -181,13 +186,10 @@ def test_remote_layer_should_not_be_used_as_datalayer_for_created_features(
|
|
|
181
186
|
expect(layers).to_have_count(2)
|
|
182
187
|
|
|
183
188
|
|
|
184
|
-
def test_can_hide_datalayer_from_caption(
|
|
185
|
-
# Faster than doing a login
|
|
186
|
-
map.edit_status = Map.ANONYMOUS
|
|
187
|
-
map.save()
|
|
189
|
+
def test_can_hide_datalayer_from_caption(openmap, live_server, datalayer, page):
|
|
188
190
|
# Add another DataLayer
|
|
189
|
-
other = DataLayerFactory(map=
|
|
190
|
-
page.goto(f"{live_server.url}{
|
|
191
|
+
other = DataLayerFactory(map=openmap, name="Hidden", settings={"inCaption": False})
|
|
192
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
|
191
193
|
toggle = page.get_by_text("About").first
|
|
192
194
|
expect(toggle).to_be_visible()
|
|
193
195
|
toggle.click()
|
|
@@ -199,28 +201,6 @@ def test_can_hide_datalayer_from_caption(map, live_server, datalayer, page):
|
|
|
199
201
|
expect(hidden).to_be_hidden()
|
|
200
202
|
|
|
201
203
|
|
|
202
|
-
def test_basic_choropleth_map(map, live_server, page):
|
|
203
|
-
path = Path(__file__).parent.parent / "fixtures/choropleth_region_chomage.geojson"
|
|
204
|
-
data = json.loads(path.read_text())
|
|
205
|
-
DataLayerFactory(data=data, map=map)
|
|
206
|
-
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
207
|
-
# Hauts-de-France
|
|
208
|
-
paths = page.locator("path[fill='#08519c']")
|
|
209
|
-
expect(paths).to_have_count(1)
|
|
210
|
-
# Occitanie
|
|
211
|
-
paths = page.locator("path[fill='#3182bd']")
|
|
212
|
-
expect(paths).to_have_count(1)
|
|
213
|
-
# Grand-Est, PACA
|
|
214
|
-
paths = page.locator("path[fill='#6baed6']")
|
|
215
|
-
expect(paths).to_have_count(2)
|
|
216
|
-
# Bourgogne-Franche-Comté, Centre-Val-de-Loire, IdF, Normandie, Corse, Nouvelle-Aquitaine
|
|
217
|
-
paths = page.locator("path[fill='#bdd7e7']")
|
|
218
|
-
expect(paths).to_have_count(6)
|
|
219
|
-
# Bretagne, Pays de la Loire, AURA
|
|
220
|
-
paths = page.locator("path[fill='#eff3ff']")
|
|
221
|
-
expect(paths).to_have_count(3)
|
|
222
|
-
|
|
223
|
-
|
|
224
204
|
def test_minimap_on_load(map, live_server, datalayer, page):
|
|
225
205
|
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
|
226
206
|
expect(page.locator(".leaflet-control-minimap")).to_be_hidden()
|
|
@@ -231,3 +231,21 @@ def test_can_change_owner(map, live_server, login, user):
|
|
|
231
231
|
save.click()
|
|
232
232
|
modified = Map.objects.get(pk=map.pk)
|
|
233
233
|
assert modified.owner == user
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def test_can_delete_datalayer(live_server, map, login, datalayer):
|
|
237
|
+
page = login(map.owner)
|
|
238
|
+
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
|
239
|
+
layers = page.locator(".umap-browse-datalayers li")
|
|
240
|
+
markers = page.locator(".leaflet-marker-icon")
|
|
241
|
+
expect(layers).to_have_count(1)
|
|
242
|
+
expect(markers).to_have_count(1)
|
|
243
|
+
page.get_by_role("link", name="Manage layers").click()
|
|
244
|
+
page.once("dialog", lambda dialog: dialog.accept())
|
|
245
|
+
page.locator("#umap-ui-container").get_by_title("Delete layer").click()
|
|
246
|
+
with page.expect_response(re.compile(r".*/datalayer/delete/.*")):
|
|
247
|
+
page.get_by_role("button", name="Save").click()
|
|
248
|
+
expect(markers).to_have_count(0)
|
|
249
|
+
# FIXME does not work, resolve to 1 element, even if this command is empty:
|
|
250
|
+
# document.querySelectorAll(".umap-browse-datalayers li")
|
|
251
|
+
# expect(layers).to_have_count(0)
|
|
@@ -5,7 +5,7 @@ import pytest
|
|
|
5
5
|
from django.core.files.base import ContentFile
|
|
6
6
|
from playwright.sync_api import expect
|
|
7
7
|
|
|
8
|
-
from umap.models import
|
|
8
|
+
from umap.models import Pictogram
|
|
9
9
|
|
|
10
10
|
from ..base import DataLayerFactory
|
|
11
11
|
|
|
@@ -37,12 +37,9 @@ def pictos():
|
|
|
37
37
|
Pictogram(name="circle", pictogram=ContentFile(path.read_text(), path.name)).save()
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def test_can_change_picto_at_map_level(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
map.save()
|
|
44
|
-
DataLayerFactory(map=map, data=DATALAYER_DATA)
|
|
45
|
-
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
|
40
|
+
def test_can_change_picto_at_map_level(openmap, live_server, page, pictos):
|
|
41
|
+
DataLayerFactory(map=openmap, data=DATALAYER_DATA)
|
|
42
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
46
43
|
marker = page.locator(".umap-div-icon img")
|
|
47
44
|
expect(marker).to_have_count(1)
|
|
48
45
|
# Should have default img
|
|
@@ -71,13 +68,11 @@ def test_can_change_picto_at_map_level(map, live_server, page, pictos):
|
|
|
71
68
|
expect(marker).to_have_attribute("src", "/static/umap/img/marker.svg")
|
|
72
69
|
|
|
73
70
|
|
|
74
|
-
def test_can_change_picto_at_datalayer_level(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
map
|
|
78
|
-
|
|
79
|
-
DataLayerFactory(map=map, data=DATALAYER_DATA)
|
|
80
|
-
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
|
71
|
+
def test_can_change_picto_at_datalayer_level(openmap, live_server, page, pictos):
|
|
72
|
+
openmap.settings["properties"]["iconUrl"] = "/uploads/pictogram/star.svg"
|
|
73
|
+
openmap.save()
|
|
74
|
+
DataLayerFactory(map=openmap, data=DATALAYER_DATA)
|
|
75
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
81
76
|
marker = page.locator(".umap-div-icon img")
|
|
82
77
|
expect(marker).to_have_count(1)
|
|
83
78
|
# Should have default img
|
|
@@ -112,13 +107,11 @@ def test_can_change_picto_at_datalayer_level(map, live_server, page, pictos):
|
|
|
112
107
|
expect(marker).to_have_attribute("src", "/uploads/pictogram/star.svg")
|
|
113
108
|
|
|
114
109
|
|
|
115
|
-
def test_can_change_picto_at_marker_level(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
map
|
|
119
|
-
|
|
120
|
-
DataLayerFactory(map=map, data=DATALAYER_DATA)
|
|
121
|
-
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
|
110
|
+
def test_can_change_picto_at_marker_level(openmap, live_server, page, pictos):
|
|
111
|
+
openmap.settings["properties"]["iconUrl"] = "/uploads/pictogram/star.svg"
|
|
112
|
+
openmap.save()
|
|
113
|
+
DataLayerFactory(map=openmap, data=DATALAYER_DATA)
|
|
114
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
122
115
|
marker = page.locator(".umap-div-icon img")
|
|
123
116
|
expect(marker).to_have_count(1)
|
|
124
117
|
# Should have default img
|
|
@@ -152,12 +145,9 @@ def test_can_change_picto_at_marker_level(map, live_server, page, pictos):
|
|
|
152
145
|
expect(marker).to_have_attribute("src", "/uploads/pictogram/star.svg")
|
|
153
146
|
|
|
154
147
|
|
|
155
|
-
def test_can_use_remote_url_as_picto(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
map.save()
|
|
159
|
-
DataLayerFactory(map=map, data=DATALAYER_DATA)
|
|
160
|
-
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
|
148
|
+
def test_can_use_remote_url_as_picto(openmap, live_server, page, pictos):
|
|
149
|
+
DataLayerFactory(map=openmap, data=DATALAYER_DATA)
|
|
150
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
161
151
|
marker = page.locator(".umap-div-icon img")
|
|
162
152
|
expect(marker).to_have_count(1)
|
|
163
153
|
# Should have default img
|
|
@@ -195,12 +185,9 @@ def test_can_use_remote_url_as_picto(map, live_server, page, pictos):
|
|
|
195
185
|
expect(symbols).to_have_count(1)
|
|
196
186
|
|
|
197
187
|
|
|
198
|
-
def test_can_use_char_as_picto(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
map.save()
|
|
202
|
-
DataLayerFactory(map=map, data=DATALAYER_DATA)
|
|
203
|
-
page.goto(f"{live_server.url}{map.get_absolute_url()}?edit")
|
|
188
|
+
def test_can_use_char_as_picto(openmap, live_server, page, pictos):
|
|
189
|
+
DataLayerFactory(map=openmap, data=DATALAYER_DATA)
|
|
190
|
+
page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit")
|
|
204
191
|
marker = page.locator(".umap-div-icon span")
|
|
205
192
|
# Should have default img, so not a span
|
|
206
193
|
expect(marker).to_have_count(0)
|