Skip to content

Commit

Permalink
test: add test for legendurl in wmts capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed Jul 17, 2024
1 parent ff36f70 commit 99644d3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
14 changes: 14 additions & 0 deletions mapproxy/test/system/fixture/legendgraphic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
email: [email protected]
access_constraints:
Here be dragons.
wmts:

layers:
- name: wms_legend
Expand All @@ -45,6 +46,13 @@ layers:
title: Layer with a static LegendURL
legendurl: http://localhost:42423/staticlegend_layer.png
sources: [legendurl_static_2]
- name: wmts_layer_legendurl
title: WMTS Layer with a static LegendURL
legendurl: http://localhost:42423/staticlegend_layer.png
sources: [tile_cache]
- name: wmts_layer_no_legendurl
title: WMTS Layer without a static LegendURL
sources: [tile_cache]

sources:
legend_cache:
Expand Down Expand Up @@ -91,3 +99,9 @@ sources:
url: http://localhost:42423/service
layers: foo

caches:
tile_cache:
cache:
type: file
grids: [GLOBAL_WEBMERCATOR]
sources: []
23 changes: 21 additions & 2 deletions mapproxy/test/system/test_legendgraphic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
WMS111LegendGraphicRequest,
WMS130LegendGraphicRequest,
)
from mapproxy.request.wmts import WMTS100CapabilitiesRequest

from mapproxy.test.image import is_png, tmp_image
from mapproxy.test.helper import validate_with_dtd, validate_with_xsd
from mapproxy.test.http import mock_httpd
from mapproxy.test.system import SysTest
from mapproxy.test.system.test_wms import is_111_capa, assert_xpath_wms130, ns130
from mapproxy.test.system.test_wmts import assert_xpath_wmts, ns_wmts


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -64,6 +66,10 @@ def setup_method(self):
url="/service?",
param=dict(format="image/png", layer="wms_legend", sld_version="1.1.0"),
)
self.common_wmts_cap_req = WMTS100CapabilitiesRequest(
url="/service?",
param=dict(service="WMTS", version="1.0.0", request="GetCapabilities"),
)

# test_00, test_01, test_02 need to run first in order to run the other tests properly
def test_00_get_legendgraphic_multiple_sources_111(self, app):
Expand Down Expand Up @@ -145,8 +151,8 @@ def test_capabilities_111(self, app):
xml.xpath("//Layer/Style/LegendURL/@height"),
)
assert legend_sizes == (
["256", "256", "256", "256"],
["512", "768", "256", "256"],
["256", "256", "256", "256", "256"],
["512", "768", "256", "256", "256"],
)
layer_urls = xml.xpath(
"//Layer/Style/LegendURL/OnlineResource/@xlink:href", namespaces=ns130
Expand Down Expand Up @@ -306,3 +312,16 @@ def test_get_legendgraphic_json_single_source_multiple_sub_layers(self, app):
json_data = json.loads(json_str)
assert json_data['Legend'][0]['layerName'] == 'foo'
assert json_data['Legend'][1]['layerName'] == 'bar'

def test_wmts_legend_url(self, app):
resp = app.get(self.common_wmts_cap_req)
assert resp.content_type == "application/xml"
xml = resp.lxml
assert_xpath_wmts(
xml,
'//wmts:Layer[1]/wmts:Style/wmts:LegendURL/@xlink:href',
'http://localhost/service?service=WMS&request=GetLegendGraphic&version=1.3.0&format=image%2Fpng'
'&layer=wmts_layer_legendurl'
)
assert xml.xpath('count(//wmts:Layer)', namespaces=ns_wmts) == 2
assert xml.xpath('count(//wmts:LegendURL)', namespaces=ns_wmts) == 1

0 comments on commit 99644d3

Please sign in to comment.