Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Tests][Server] Add test for WMS SLD parameter and move SLD_BODY test
  • Loading branch information
rldhont committed Sep 27, 2018
1 parent c15f05b commit 34009d3
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/src/python/test_qgsserver_wms_getmap.py
Expand Up @@ -1109,6 +1109,76 @@ def test_wms_getmap_annotations(self):
self._img_diff_error(r, h, "WMS_GetMap_Annotations")

def test_wms_getmap_sld(self):
import socketserver
import threading
import http.server

# Bring up a simple HTTP server
os.chdir(unitTestDataPath() + '')
handler = http.server.SimpleHTTPRequestHandler

httpd = socketserver.TCPServer(('localhost', 0), handler)
port = httpd.server_address[1]

httpd_thread = threading.Thread(target=httpd.serve_forever)
httpd_thread.setDaemon(True)
httpd_thread.start()

qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": "Country,db_point",
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "-16817707,-4710778,5696513,14587125",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_SLDRestored")

qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"REQUEST": "GetMap",
"VERSION": "1.1.1",
"SERVICE": "WMS",
"SLD": "http://localhost:" + str(port) + "/qgis_local_server/db_point.sld",
"BBOX": "-16817707,-4710778,5696513,14587125",
"WIDTH": "500",
"HEIGHT": "500",
"LAYERS": "db_point",
"STYLES": "",
"FORMAT": "image/png",
"CRS": "EPSG:3857"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_SLD")

qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": "Country,db_point",
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "-16817707,-4710778,5696513,14587125",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_SLDRestored")

httpd.server_close()

def test_wms_getmap_sld_body(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
Expand Down
34 changes: 34 additions & 0 deletions tests/testdata/qgis_local_server/db_point.sld
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" version="1.1.0" xmlns:se="http://www.opengis.net/se" xmlns:xlink="http://www.w3.org/1999/xlink">
<NamedLayer>
<se:Name>db_point</se:Name>
<UserStyle>
<se:Name>db_point_style</se:Name>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>Single symbol</se:Name>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>gid</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PointSymbolizer uom="http://www.opengeospatial.org/se/units/metre">
<se:Graphic>
<se:Mark>
<se:WellKnownName>square</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">5e86a1</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>0.007</se:Size>
</se:Graphic>
</se:PointSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

0 comments on commit 34009d3

Please sign in to comment.