Skip to content

Commit

Permalink
Assert response of Get Workspace Map File
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Oct 2, 2023
1 parent ed7ba7f commit 7c3dce9
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"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": "map_v2_0_0_post",
"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ční body administrativních celků",
"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://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": "HSLayers.Layer.WMS",
"singleTile": true,
"url": "https://enjoychallenge.tech/new-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": "https://enjoychallenge.tech/new-client-proxy/geoserver/test_map_json_workspace/wfs"
},
"ratio": 1.5,
"singleTile": true,
"title": "Mista",
"visibility": false,
"wmsMaxScale": 0
}
],
"name": "map_v2_0_0_post",
"user": {
"email": "",
"name": "test_map_json_workspace"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"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": "map_v3_0_0_post",
"name": "map_v3_0_0_post",
"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": "https://enjoychallenge.tech/new-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": "https://enjoychallenge.tech/new-client-proxy/geoserver/test_map_json_workspace/wfs"
},
"ratio": 1.5,
"singleTile": true,
"title": "Mista",
"visibility": false,
"wmsMaxScale": 0
}
],
"user": {
"email": "",
"name": "test_map_json_workspace"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os

from layman import app
Expand All @@ -19,9 +20,11 @@
TEST_CASES = {
'v2_0_0': {
'file_path': os.path.join(DIRECTORY, '2_0_0_external_wms_internal_wms_internal_wfs.json'),
'exp_map_file': os.path.join(DIRECTORY, 'exp_2_0_0_map_file.json'),
},
'v3_0_0': {
'file_path': os.path.join(DIRECTORY, '3_0_0_external_wms_internal_wms_internal_wfs.json'),
'exp_map_file': os.path.join(DIRECTORY, 'exp_3_0_0_map_file.json'),
},
}

Expand All @@ -41,6 +44,7 @@ class TestPublication(base_test.TestSingleRestPublication):
rest_args={
'file_paths': [params['file_path']]
},
params=params,
specific_types={
(base_test_classes.RestMethod.POST, ): EnumTestTypes.MANDATORY
}
Expand All @@ -57,8 +61,19 @@ def before_class(self):
],
}, scope='class')

@staticmethod
def assert_get_workspace_map_file(map, exp_file):
headers = {'X-Forwarded-Proto': 'https',
'X-Forwarded-Host': 'enjoychallenge.tech',
'X-Forwarded-Prefix': '/new-client-proxy',
}

def test_publication(self, map, rest_method, rest_args):
resp = process_client.get_workspace_map_file(map.type, map.workspace, map.name, headers=headers)
with open(exp_file, encoding='utf-8') as file:
orig_json = json.load(file)
assert resp == orig_json

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

Expand All @@ -80,3 +95,5 @@ def test_publication(self, map, rest_method, rest_args):
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)

self.assert_get_workspace_map_file(map, params['exp_map_file'])

0 comments on commit 7c3dce9

Please sign in to comment.