diff --git a/tests/src/python/test_qgsserver_wms_getmap.py b/tests/src/python/test_qgsserver_wms_getmap.py index 67c8d75bb5b1..f83c15af8cea 100644 --- a/tests/src/python/test_qgsserver_wms_getmap.py +++ b/tests/src/python/test_qgsserver_wms_getmap.py @@ -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", diff --git a/tests/testdata/qgis_local_server/db_point.sld b/tests/testdata/qgis_local_server/db_point.sld new file mode 100644 index 000000000000..19ae934ee645 --- /dev/null +++ b/tests/testdata/qgis_local_server/db_point.sld @@ -0,0 +1,34 @@ + + + + db_point + + db_point_style + + + Single symbol + + + gid + 1 + + + + + + square + + 5e86a1 + + + 000000 + + + 0.007 + + + + + + + \ No newline at end of file