Fix integration tests for download view
This commit is contained in:
parent
30e83a143c
commit
2274243662
6 changed files with 13 additions and 155 deletions
|
@ -1138,7 +1138,7 @@ L.U.Map.include({
|
|||
const link = L.DomUtil.createLink(
|
||||
'button',
|
||||
container,
|
||||
L._('Download uMap backup format'),
|
||||
L._('Download full data'),
|
||||
downloadUrl
|
||||
)
|
||||
let name = this.options.name || 'data'
|
||||
|
|
|
@ -101,131 +101,5 @@ describe('L.U.Map.Export', function () {
|
|||
'<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><name>name poly</name><ExtendedData><Data name="name"><value>name poly</value></Data></ExtendedData><Polygon><outerBoundaryIs><LinearRing><coordinates>11.25,53.585984 10.151367,52.975108 12.689209,52.167194 14.084473,53.199452 12.634277,53.618579 11.25,53.585984 11.25,53.585984</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>test</name><ExtendedData><Data name="_umap_options"><value>[object Object]</value></Data><Data name="name"><value>test</value></Data></ExtendedData><Point><coordinates>-0.274658,52.57635</coordinates></Point></Placemark><Placemark><name>test</name><ExtendedData><Data name="_umap_options"><value>[object Object]</value></Data><Data name="name"><value>test</value></Data></ExtendedData><LineString><coordinates>-0.571289,54.476422 0.439453,54.610255 1.724854,53.448807 4.163818,53.988395 5.306396,53.533778 6.591797,53.709714 7.042236,53.350551</coordinates></LineString></Placemark></Document></kml>'
|
||||
assert.equal(content, expected)
|
||||
})
|
||||
|
||||
it('should export to umap', function () {
|
||||
const { content, filetype, filename } = this.map.format('umap')
|
||||
assert.equal(filetype, 'application/json')
|
||||
assert.equal(filename, 'name_of_the_map.umap')
|
||||
const expected = {
|
||||
type: 'umap',
|
||||
uri: null,
|
||||
properties: {
|
||||
easing: false,
|
||||
embedControl: true,
|
||||
fullscreenControl: true,
|
||||
searchControl: true,
|
||||
datalayersControl: true,
|
||||
zoomControl: true,
|
||||
permanentCreditBackground: true,
|
||||
slideshow: {},
|
||||
captionMenus: true,
|
||||
captionBar: false,
|
||||
limitBounds: {},
|
||||
overlay: null,
|
||||
tilelayer: {
|
||||
attribution: 'HOT and friends',
|
||||
name: 'HOT OSM-fr server',
|
||||
url_template: 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
|
||||
rank: 99,
|
||||
minZoom: 0,
|
||||
maxZoom: 20,
|
||||
id: 2,
|
||||
},
|
||||
licence: '',
|
||||
description: 'The description of the map',
|
||||
name: 'name of the map',
|
||||
displayPopupFooter: false,
|
||||
miniMap: false,
|
||||
moreControl: true,
|
||||
scaleControl: true,
|
||||
scrollWheelZoom: true,
|
||||
zoom: 6,
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [5.0592041015625, 52.05924589011585],
|
||||
},
|
||||
layers: [
|
||||
{
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
name: 'name poly',
|
||||
},
|
||||
geometry: {
|
||||
type: 'Polygon',
|
||||
coordinates: [
|
||||
[
|
||||
[11.25, 53.585984],
|
||||
[10.151367, 52.975108],
|
||||
[12.689209, 52.167194],
|
||||
[14.084473, 53.199452],
|
||||
[12.634277, 53.618579],
|
||||
[11.25, 53.585984],
|
||||
[11.25, 53.585984],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
_umap_options: {
|
||||
color: 'OliveDrab',
|
||||
},
|
||||
name: 'test',
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [-0.274658, 52.57635],
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
_umap_options: {
|
||||
fill: false,
|
||||
},
|
||||
name: 'test',
|
||||
},
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
coordinates: [
|
||||
[-0.571289, 54.476422],
|
||||
[0.439453, 54.610255],
|
||||
[1.724854, 53.448807],
|
||||
[4.163818, 53.988395],
|
||||
[5.306396, 53.533778],
|
||||
[6.591797, 53.709714],
|
||||
[7.042236, 53.350551],
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
_umap_options: {
|
||||
displayOnLoad: true,
|
||||
browsable: true,
|
||||
editMode: 'advanced',
|
||||
iconClass: 'Default',
|
||||
name: 'Elephants',
|
||||
id: 62,
|
||||
pictogram_url: null,
|
||||
opacity: null,
|
||||
weight: null,
|
||||
fillColor: '',
|
||||
color: '',
|
||||
stroke: true,
|
||||
smoothFactor: null,
|
||||
dashArray: '',
|
||||
fillOpacity: null,
|
||||
fill: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
assert.deepEqual(JSON.parse(content), expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -71,13 +71,11 @@ class MapFactory(factory.django.DjangoModelFactory):
|
|||
"properties": {
|
||||
"datalayersControl": True,
|
||||
"description": "Which is just the Danube, at the end",
|
||||
"displayCaptionOnLoad": False,
|
||||
"displayDataBrowserOnLoad": False,
|
||||
"displayPopupFooter": False,
|
||||
"licence": "",
|
||||
"miniMap": False,
|
||||
"moreControl": True,
|
||||
"name": "Cruising on the Donau",
|
||||
"name": name,
|
||||
"scaleControl": True,
|
||||
"tilelayer": {
|
||||
"attribution": "\xa9 OSM Contributors",
|
||||
|
@ -100,6 +98,7 @@ class MapFactory(factory.django.DjangoModelFactory):
|
|||
def _adjust_kwargs(cls, **kwargs):
|
||||
# Make sure there is no persistency
|
||||
kwargs["settings"] = copy.deepcopy(kwargs["settings"])
|
||||
kwargs["settings"]["properties"]["name"] = kwargs["name"]
|
||||
return kwargs
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -9,12 +9,12 @@ pytestmark = pytest.mark.django_db
|
|||
|
||||
def test_umap_export(map, live_server, datalayer, page):
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}?share")
|
||||
button = page.get_by_role("button", name="Download data")
|
||||
expect(button).to_be_visible()
|
||||
link = page.get_by_role("link", name="Download full data")
|
||||
expect(link).to_be_visible()
|
||||
with page.expect_download() as download_info:
|
||||
button.click()
|
||||
link.click()
|
||||
download = download_info.value
|
||||
assert download.suggested_filename == "test_map.umap"
|
||||
assert download.suggested_filename == "umap_backup_test-map.umap"
|
||||
path = Path("/tmp/") / download.suggested_filename
|
||||
download.save_as(path)
|
||||
downloaded = json.loads(path.read_text())
|
||||
|
@ -29,14 +29,12 @@ def test_umap_export(map, live_server, datalayer, page):
|
|||
"_umap_options": {
|
||||
"browsable": True,
|
||||
"displayOnLoad": True,
|
||||
"editMode": "disabled",
|
||||
"inCaption": True,
|
||||
"name": "test datalayer",
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"geometry": {
|
||||
"coordinates": [13.688965, 48.552978],
|
||||
"coordinates": [13.68896484375, 48.55297816440071],
|
||||
"type": "Point",
|
||||
},
|
||||
"properties": {
|
||||
|
@ -51,25 +49,14 @@ def test_umap_export(map, live_server, datalayer, page):
|
|||
}
|
||||
],
|
||||
"properties": {
|
||||
"captionBar": False,
|
||||
"captionMenus": True,
|
||||
"datalayersControl": True,
|
||||
"description": "Which is just the Danube, at the end",
|
||||
"displayPopupFooter": False,
|
||||
"easing": False,
|
||||
"embedControl": True,
|
||||
"fullscreenControl": True,
|
||||
"licence": "",
|
||||
"limitBounds": {},
|
||||
"miniMap": False,
|
||||
"moreControl": True,
|
||||
"name": "test map",
|
||||
"overlay": None,
|
||||
"permanentCreditBackground": True,
|
||||
"scaleControl": True,
|
||||
"scrollWheelZoom": True,
|
||||
"searchControl": True,
|
||||
"slideshow": {},
|
||||
"tilelayer": {
|
||||
"attribution": "© OSM Contributors",
|
||||
"maxZoom": 18,
|
||||
|
|
|
@ -612,7 +612,7 @@ def test_download(client, map, datalayer):
|
|||
# Test response is a json
|
||||
j = json.loads(response.content.decode())
|
||||
assert j["type"] == "umap"
|
||||
assert j["uri"] == "http://testserver/en/map/test-map_1"
|
||||
assert j["uri"] == f"http://testserver/en/map/test-map_{map.pk}"
|
||||
assert j["geometry"] == {
|
||||
"coordinates": [13.447265624999998, 48.94415123418794],
|
||||
"type": "Point",
|
||||
|
@ -620,13 +620,11 @@ def test_download(client, map, datalayer):
|
|||
assert j["properties"] == {
|
||||
"datalayersControl": True,
|
||||
"description": "Which is just the Danube, at the end",
|
||||
"displayCaptionOnLoad": False,
|
||||
"displayDataBrowserOnLoad": False,
|
||||
"displayPopupFooter": False,
|
||||
"licence": "",
|
||||
"miniMap": False,
|
||||
"moreControl": True,
|
||||
"name": "Cruising on the Donau",
|
||||
"name": "test map",
|
||||
"scaleControl": True,
|
||||
"tilelayer": {
|
||||
"attribution": "© OSM Contributors",
|
||||
|
|
|
@ -289,8 +289,8 @@ def test_user_dashboard_display_user_maps(client, map):
|
|||
def test_user_dashboard_display_user_maps_distinct(client, map):
|
||||
# cf https://github.com/umap-project/umap/issues/1325
|
||||
anonymap = MapFactory(name="Map witout owner should not appear")
|
||||
user1 = UserFactory(username='user1')
|
||||
user2 = UserFactory(username='user2')
|
||||
user1 = UserFactory(username="user1")
|
||||
user2 = UserFactory(username="user2")
|
||||
map.editors.add(user1)
|
||||
map.editors.add(user2)
|
||||
map.save()
|
||||
|
@ -298,7 +298,7 @@ def test_user_dashboard_display_user_maps_distinct(client, map):
|
|||
response = client.get(reverse("user_dashboard"))
|
||||
assert response.status_code == 200
|
||||
body = response.content.decode()
|
||||
assert body.count(map.name) == 1
|
||||
assert body.count(f'<a href="/en/map/test-map_{map.pk}">test map</a>') == 1
|
||||
assert body.count(anonymap.name) == 0
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue