Skip to content

Commit

Permalink
Test map_by_schema_version
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Sep 29, 2023
1 parent 1595a9f commit 910b761
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 0 deletions.
54 changes: 54 additions & 0 deletions sample/layman.map/full_3_0_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/3.0.0/schema.json",
"schema_version": "3.0.0",
"abstract": "Na tematick\u00e9 map\u011b p\u0159i p\u0159ibl\u00ed\u017een\u00ed jsou postupn\u011b zobrazovan\u00e9 administrativn\u00ed celky Libereck\u00e9ho kraje : okresy, OP\u00da, ORP a obce.",
"title": "Administrativn\u00ed \u010dlen\u011bn\u00ed Libereck\u00e9ho kraje",
"extent": [
14.62,
50.58,
15.42,
50.82
],
"nativeExtent": [
1627490.9553976597,
6547334.172794042,
1716546.5480322787,
6589515.35758913
],
"user": {
"email": "[email protected]",
"name": "Test User"
},
"groups": {
"guest": "r"
},
"scale": 1,
"projection": "epsg:3857",
"center": [
1672068,
6568819
],
"units": "m",
"layers": [
{
"metadata": {},
"visibility": false,
"opacity": 1,
"title": "Jednoduch\u00e1 podkladov\u00e1 mapa",
"className": "WMS",
"singleTile": true,
"maxResolution": null,
"minResolution": 0,
"url": "https://geoportal.kraj-lbc.cz/cgi-bin/mapserv?map=/data/gis/MapServer/projects/wms/atlas/puda.map&",
"params": {
"LAYERS": "podkladova_mapa",
"FORMAT": "image\/png",
"ABSTRACT": "Jednoduch\u00e1 podkladov\u00e1 mapa Libereck\u00e9ho kraje"
},
"ratio": 1.5
}
],
"current_base_layer": {
"title": "Topografick\u00e1 podkladov\u00e1 mapa (\u0161edo\u0161k\u00e1l\u00e1)"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/2.0.0/schema.json",
"schema_version": "2.0.0",
"abstract": "World places and boundaries abstract",
"title": "World places and boundaries",
"extent": [
-35.0,
-48.5,
179,
81.5
],
"nativeExtent": [
-3896182.18,
-6190443.81,
19926188.85,
16579785.82
],
"projection": "epsg:3857",
"layers": [
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Defini\u010dn\u00ed body administrativn\u00edch celk\u016f",
"className": "HSLayers.Layer.WMS",
"singleTile": true,
"wmsMaxScale": 0,
"legends": [
"https%3A%2F%2Fgeoportal.kraj-lbc.cz%2Fcgi-bin%2Fmapserv%3Fmap%3D%2Fdata%2Fgis%2FMapServer%2Fprojects%2Fwms%2Fatlas%2Fadministrativni_cleneni.map%26version%3D1.3.0%26service%3DWMS%26request%3DGetLegendGraphic%26sld_version%3D1.1.0%26layer%3Ddefinicni_body_administrativnich_celku%26format%3Dimage%2Fpng%26STYLE%3Ddefault"
],
"maxResolution": null,
"minResolution": 0,
"url": "https%3A%2F%2Fgeoportal.kraj-lbc.cz%2Fcgi-bin%2Fmapserv%3Fmap%3D%2Fdata%2Fgis%2FMapServer%2Fprojects%2Fwms%2Fatlas%2Fadministrativni_cleneni.map%26",
"params": {
"LAYERS": "definicni_body_administrativnich_celku",
"INFO_FORMAT": "application\/vnd.ogc.gml",
"FORMAT": "image\/png",
"FROMCRS": "EPSG:3857",
"VERSION": "1.3.0"
},
"dimensions": {}
},
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Hranice",
"className": "HSLayers.Layer.WMS",
"singleTile": true,
"url": "http://localhost:8000/some-client-proxy/geoserver/test_map_json_workspace_wms/ows",
"params": {
"LAYERS": "hranice",
"FORMAT": "image\/png"
}
},
{
"className": "OpenLayers.Layer.Vector",
"dimensions": {},
"legends": [
""
],
"maxResolution": null,
"metadata": {},
"minResolution": 0,
"name": "mista",
"opacity": 1,
"protocol": {
"format": "hs.format.WFS",
"url": "http://localhost:8000/some-other-client-proxy/geoserver/test_map_json_workspace/wfs"
},
"ratio": 1.5,
"singleTile": true,
"title": "Mista",
"visibility": false,
"wmsMaxScale": 0
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/3.0.0/schema.json",
"schema_version": "2.0.0",
"abstract": "World places and boundaries abstract",
"title": "World places and boundaries",
"extent": [
-35.0,
-48.5,
179,
81.5
],
"nativeExtent": [
-3896182.18,
-6190443.81,
19926188.85,
16579785.82
],
"projection": "epsg:3857",
"layers": [
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Defini\u010dn\u00ed body administrativn\u00edch celk\u016f",
"className": "WMS",
"singleTile": true,
"wmsMaxScale": 0,
"legends": [
"https://geoportal.kraj-lbc.cz/cgi-bin/mapserv?map=/data/gis/MapServer/projects/wms/atlas/administrativni_cleneni.map&version=1.3.0&service=WMS&request=GetLegendGraphic&sld_version=1.1.0&layer=definicni_body_administrativnich_celku&format=image/png&STYLE=default"
],
"maxResolution": null,
"minResolution": 0,
"url": "https://geoportal.kraj-lbc.cz/cgi-bin/mapserv?map=/data/gis/MapServer/projects/wms/atlas/administrativni_cleneni.map&",
"params": {
"LAYERS": "definicni_body_administrativnich_celku",
"INFO_FORMAT": "application\/vnd.ogc.gml",
"FORMAT": "image\/png",
"FROMCRS": "EPSG:3857",
"VERSION": "1.3.0"
},
"dimensions": {}
},
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Hranice",
"className": "WMS",
"singleTile": true,
"url": "http://localhost:8000/some-client-proxy/geoserver/test_map_json_workspace_wms/ows",
"params": {
"LAYERS": "hranice",
"FORMAT": "image\/png"
}
},
{
"className": "Vector",
"dimensions": {},
"legends": [],
"maxResolution": null,
"metadata": {},
"minResolution": 0,
"name": "mista",
"opacity": 1,
"protocol": {
"format": "WFS",
"url": "http://localhost:8000/some-other-client-proxy/geoserver/test_map_json_workspace/wfs"
},
"ratio": 1.5,
"singleTile": true,
"title": "Mista",
"visibility": false,
"wmsMaxScale": 0
}
]
}
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions tests/dynamic_data/publications/map_by_schema_version/map_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import os

from layman import app
from layman.util import get_publication_info
from test_tools import process_client
from tests import EnumTestTypes, Publication
from tests.asserts.final import publication as asserts_publ
from tests.asserts.final.publication import util as assert_util
from tests.dynamic_data import base_test, base_test_classes


DIRECTORY = os.path.dirname(os.path.abspath(__file__))


WORKSPACE = 'test_map_json_workspace'
LAYER_HRANICE = Publication(WORKSPACE, process_client.LAYER_TYPE, 'hranice')


TEST_CASES = {
'v2_0_0': {
'file_path': os.path.join(DIRECTORY, '2_0_0_external_wms_internal_wms_internal_wfs.json'),
},
'v3_0_0': {
'file_path': os.path.join(DIRECTORY, '3_0_0_external_wms_internal_wms_internal_wfs.json'),
},
}

pytest_generate_tests = base_test.pytest_generate_tests


class TestPublication(base_test.TestSingleRestPublication):
workspace = WORKSPACE
publication_type = process_client.MAP_TYPE

rest_parametrization = [
base_test_classes.RestMethod
]

test_cases = [base_test.TestCaseType(key=key,
type=EnumTestTypes.OPTIONAL,
rest_args={
'file_paths': [params['file_path']]
},
specific_types={
(base_test_classes.RestMethod.POST, ): EnumTestTypes.MANDATORY
}
) for key, params in TEST_CASES.items()]

def before_class(self):
self.post_publication(LAYER_HRANICE, args={
'file_paths': [
'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.cpg',
'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.dbf',
'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.prj',
'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.shp',
'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.shx',
],
}, scope='class')


def test_publication(self, map, rest_method, rest_args):
rest_method.fn(map, args=rest_args)
assert_util.is_publication_valid_and_complete(map)

with app.app_context():
publ_info = get_publication_info(map.workspace, map.type, map.name,
context={'keys': ['map_layers']})

assert publ_info['_map_layers'] == [
{'index': 1,
'name': 'hranice',
'uuid': self.publ_uuids[LAYER_HRANICE],
'workspace': self.workspace},
{'index': 2,
'name': 'mista',
'uuid': None,
'workspace': self.workspace},
]

exp_thumbnail = os.path.join(DIRECTORY, 'exp_thumbnail.png')
asserts_publ.internal.thumbnail_equals(map.workspace, map.type, map.name, exp_thumbnail,
max_diffs=0)

0 comments on commit 910b761

Please sign in to comment.