Skip to content

Commit

Permalink
Add second map to map_layer_relation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Sep 13, 2023
1 parent 9d2cbba commit f04e0ee
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 87 deletions.
57 changes: 0 additions & 57 deletions sample/layman.map/internal_url_thumbnail.json

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"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": "Hranice",
"className": "HSLayers.Layer.WMS",
"singleTile": true,
"url": "http://localhost:8000/geoserver/layer_map_relation_workspace_wms/ows",
"params": {
"LAYERS": "hranice",
"FORMAT": "image\/png"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
WORKSPACE = 'layer_map_relation_workspace'

LAYER_HRANICE = Publication(WORKSPACE, process_client.LAYER_TYPE, 'hranice')
LAYER_MISTA_NON_EXISTENT = Publication(WORKSPACE, process_client.LAYER_TYPE, 'mista')
MAP_HRANICE = Publication(WORKSPACE, process_client.MAP_TYPE, 'map_hranice')
MAP_HRANICE_OPERATES_ON = [LAYER_HRANICE]

TEST_CASES = {
'post': {
Expand All @@ -30,12 +33,12 @@
},
'exp_after_rest_method': {
'map_layers': {
# workspace, layer name, layer index, exists?
(WORKSPACE, 'hranice', 1, True),
(WORKSPACE, 'mista', 2, False),
(WORKSPACE, 'hranice', 3, True),
# layer, layer index, exists?
(LAYER_HRANICE, 1, True),
(LAYER_MISTA_NON_EXISTENT, 2, False),
(LAYER_HRANICE, 3, True),
},
'operates_on': ['hranice'],
'operates_on': [LAYER_HRANICE],
},
},
'delete': {
Expand All @@ -46,11 +49,11 @@
},
'exp_before_rest_method': {
'map_layers': {
(WORKSPACE, 'hranice', 1, True),
(WORKSPACE, 'mista', 2, False),
(WORKSPACE, 'hranice', 3, True),
(LAYER_HRANICE, 1, True),
(LAYER_MISTA_NON_EXISTENT, 2, False),
(LAYER_HRANICE, 3, True),
},
'operates_on': ['hranice'],
'operates_on': [LAYER_HRANICE],
},
'exp_after_rest_method': {
'map_layers': None,
Expand All @@ -74,7 +77,7 @@ class TestPublication(base_test.TestSingleRestPublication):
type=EnumTestTypes.MANDATORY,
) for key, params in TEST_CASES.items()]

layer_uuids = {}
publ_uuids = {}

def before_class(self):
resp = self.post_publication(LAYER_HRANICE, args={
Expand All @@ -86,7 +89,12 @@ def before_class(self):
'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.shx',
],
}, scope='class')
self.layer_uuids[LAYER_HRANICE.name] = resp['uuid']
self.publ_uuids[LAYER_HRANICE] = resp['uuid']

resp = self.post_publication(MAP_HRANICE, args={
'file_paths': [os.path.join(DIRECTORY, 'internal_hranice.json')],
}, scope='class')
self.publ_uuids[MAP_HRANICE] = resp['uuid']

def assert_exp_map_layers(self, map, exp_map_layers, exp_operates_on):
with app.app_context():
Expand All @@ -101,17 +109,17 @@ def assert_exp_map_layers(self, map, exp_map_layers, exp_operates_on):
for ml in publ_info['_map_layers']
}
exp_map_layers = {
layer[:3] + ((self.layer_uuids[layer[1]] if layer[3] else None),)
for layer in exp_map_layers
(layer.workspace, layer.name, layer_index, self.publ_uuids[layer] if exists else None)
for layer, layer_index, exists in exp_map_layers
}
assert found_map_layers == exp_map_layers

exp_operates_on = [
{
"xlink:href": f"http://localhost:3080/csw?SERVICE=CSW&VERSION=2.0.2&REQUEST=GetRecordById&OUTPUTSCHEMA=http://www.isotc211.org/2005/gmd&ID=m-{self.layer_uuids[layer_name]}#_m-{self.layer_uuids[layer_name]}",
"xlink:title": layer_name,
"xlink:href": f"http://localhost:3080/csw?SERVICE=CSW&VERSION=2.0.2&REQUEST=GetRecordById&OUTPUTSCHEMA=http://www.isotc211.org/2005/gmd&ID=m-{self.publ_uuids[layer]}#_m-{self.publ_uuids[layer]}",
"xlink:title": layer.name,
}
for layer_name in exp_operates_on
for layer in exp_operates_on
]
asserts_publ.metadata.correct_values_in_metadata(
map.workspace, map.type, map.name, http_method=REQUEST_METHOD_POST, exp_values={
Expand All @@ -123,7 +131,7 @@ def assert_exp_layer_maps(layer, map_operates_on_tuples):
exp_layer_maps = sorted([
(map.workspace, map.name)
for map, operates_on in map_operates_on_tuples
if layer.name in operates_on
if layer in operates_on
])
with app.app_context():
found_layer_maps = [
Expand All @@ -135,12 +143,18 @@ def assert_exp_layer_maps(layer, map_operates_on_tuples):
def test_publication(self, map, rest_method, rest_args, params):
exp = params['exp_before_rest_method']
self.assert_exp_map_layers(map, exp['map_layers'], exp['operates_on'])
self.assert_exp_layer_maps(LAYER_HRANICE, [(map, exp['operates_on'] or [])])
self.assert_exp_layer_maps(LAYER_HRANICE, [
(MAP_HRANICE, MAP_HRANICE_OPERATES_ON),
(map, exp['operates_on'] or []),
])

rest_method(map, args=rest_args)
if rest_method == self.post_publication: # pylint: disable=W0143
assert_util.is_publication_valid_and_complete(map)

exp = params['exp_after_rest_method']
self.assert_exp_map_layers(map, exp['map_layers'], exp['operates_on'])
self.assert_exp_layer_maps(LAYER_HRANICE, [(map, exp['operates_on'] or [])])
self.assert_exp_layer_maps(LAYER_HRANICE, [
(MAP_HRANICE, MAP_HRANICE_OPERATES_ON),
(map, exp['operates_on'] or []),
])
11 changes: 0 additions & 11 deletions tests/static_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,16 +765,6 @@
'bbox': (1627490.9553976597, 6547334.172794042, 1716546.5480322787, 6589515.35758913),
},
},
(COMMON_WORKSPACE, MAP_TYPE, 'post_internal_layer'): {
DEFINITION: [
{'file_paths': ['sample/layman.map/internal_url_thumbnail.json', ]},
],
TEST_DATA: {
'layers': [(COMMON_WORKSPACE, LAYER_TYPE, 'post_blue_style'), ],
'operates_on': {(COMMON_WORKSPACE, LAYER_TYPE, 'post_blue_style'), },
'thumbnail': 'sample/style/test_sld_style_applied_in_map_thumbnail_map.png',
},
},
(OWNER, MAP_TYPE, 'post_private'): {
DEFINITION: [
{'headers': HEADERS[OWNER]},
Expand Down Expand Up @@ -848,7 +838,6 @@
# if (ws, pt, pn) in {(COMMON_WORKSPACE, LAYER_TYPE, 'post_common_sld'),
# (COMMON_WORKSPACE, LAYER_TYPE, 'post_common_qml'),
# (COMMON_WORKSPACE, LAYER_TYPE, 'post_jp2'),
# (COMMON_WORKSPACE, MAP_TYPE, 'post_internal_layer'),
# (COMMON_WORKSPACE, LAYER_TYPE, 'post_blue_style'),
# (COMMON_WORKSPACE, LAYER_TYPE, 'post_10countries_sld'),
# }}
Expand Down

0 comments on commit f04e0ee

Please sign in to comment.