Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Isolate other test_wms_getprint functions
- Loading branch information
Showing
3 changed files
with
150 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for QgsServer WMS GetPrint. | ||
From build dir, run: ctest -R PyQgsServerWMSGetPrintExtra -V | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
__author__ = 'René-Luc DHONT' | ||
__date__ = '25/06/2020' | ||
__copyright__ = 'Copyright 2020, The QGIS Project' | ||
|
||
import os | ||
|
||
# Needed on Qt 5 so that the serialization of XML is consistent among all executions | ||
os.environ['QT_HASH_SEED'] = '1' | ||
|
||
import urllib.parse | ||
|
||
from qgis.testing import unittest | ||
|
||
from test_qgsserver import QgsServerTestBase | ||
from qgis.server import QgsServerRequest | ||
|
||
|
||
class TestQgsServerWMSGetPrintExtra(QgsServerTestBase): | ||
"""QGIS Server WMS Tests for GetPrint group request""" | ||
|
||
def test_wms_getprint_selection(self): | ||
qs = "?" + "&".join(["%s=%s" % i for i in list({ | ||
"MAP": urllib.parse.quote(self.projectPath), | ||
"SERVICE": "WMS", | ||
"VERSION": "1.1.1", | ||
"REQUEST": "GetPrint", | ||
"TEMPLATE": "layoutA4", | ||
"FORMAT": "png", | ||
"LAYERS": "Country,Hello", | ||
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031", | ||
"map0:LAYERS": "Country,Hello", | ||
"CRS": "EPSG:3857", | ||
"SELECTION": "Country: 4" | ||
}.items())]) | ||
|
||
r, h = self._result(self._execute_request(qs)) | ||
self._img_diff_error(r, h, "WMS_GetPrint_Selection") | ||
|
||
def test_wms_getprint_opacity(self): | ||
qs = "?" + "&".join(["%s=%s" % i for i in list({ | ||
"MAP": urllib.parse.quote(self.projectPath), | ||
"SERVICE": "WMS", | ||
"VERSION": "1.1.1", | ||
"REQUEST": "GetPrint", | ||
"TEMPLATE": "layoutA4", | ||
"FORMAT": "png", | ||
"map0%3AEXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031", | ||
"map0:LAYERS": "Country,Hello", | ||
"CRS": "EPSG:3857", | ||
"SELECTION": "Country: 4", | ||
"LAYERS": "Country,Hello", | ||
"OPACITIES": "125,125" | ||
}.items())]) | ||
|
||
r, h = self._result(self._execute_request(qs)) | ||
self._img_diff_error(r, h, "WMS_GetPrint_Opacity") | ||
|
||
def test_wms_getprint_opacity_post(self): | ||
qs = "&".join(["%s=%s" % i for i in list({ | ||
"MAP": urllib.parse.quote(self.projectPath), | ||
"SERVICE": "WMS", | ||
"VERSION": "1.1.1", | ||
"REQUEST": "GetPrint", | ||
"TEMPLATE": "layoutA4", | ||
"FORMAT": "png", | ||
"map0%3AEXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031", | ||
"map0:LAYERS": "Country,Hello", | ||
"CRS": "EPSG:3857", | ||
"SELECTION": "Country: 4", | ||
"LAYERS": "Country,Hello", | ||
"OPACITIES": "125%2C125" | ||
}.items())]) | ||
|
||
r, h = self._result(self._execute_request('', QgsServerRequest.PostMethod, data=qs.encode('utf-8'))) | ||
self._img_diff_error(r, h, "WMS_GetPrint_Opacity") | ||
|
||
def test_wms_getprint_highlight(self): | ||
# default style | ||
qs = "?" + "&".join(["%s=%s" % i for i in list({ | ||
"MAP": urllib.parse.quote(self.projectPath), | ||
"SERVICE": "WMS", | ||
"VERSION": "1.1.1", | ||
"REQUEST": "GetPrint", | ||
"TEMPLATE": "layoutA4", | ||
"FORMAT": "png", | ||
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031", | ||
"map0:LAYERS": "Country_Labels", | ||
"map0:HIGHLIGHT_GEOM": "POLYGON((-15000000 10000000, -15000000 6110620, 2500000 6110620, 2500000 10000000, -15000000 10000000))", | ||
"map0:HIGHLIGHT_SYMBOL": "<StyledLayerDescriptor><UserStyle><Name>Highlight</Name><FeatureTypeStyle><Rule><Name>Symbol</Name><LineSymbolizer><Stroke><SvgParameter name=\"stroke\">%23ea1173</SvgParameter><SvgParameter name=\"stroke-opacity\">1</SvgParameter><SvgParameter name=\"stroke-width\">1.6</SvgParameter></Stroke></LineSymbolizer></Rule></FeatureTypeStyle></UserStyle></StyledLayerDescriptor>", | ||
"map0:HIGHLIGHT_LABELSTRING": "Highlight Layer!", | ||
"map0:HIGHLIGHT_LABELSIZE": "16", | ||
"map0:HIGHLIGHT_LABELCOLOR": "%2300FF0000", | ||
"map0:HIGHLIGHT_LABELBUFFERCOLOR": "%232300FF00", | ||
"map0:HIGHLIGHT_LABELBUFFERSIZE": "1.5", | ||
"CRS": "EPSG:3857" | ||
}.items())]) | ||
|
||
r, h = self._result(self._execute_request(qs)) | ||
assert h.get("Content-Type").startswith('image'), r | ||
self._img_diff_error(r, h, "WMS_GetPrint_Highlight") | ||
|
||
def test_wms_getprint_label(self): | ||
qs = "?" + "&".join(["%s=%s" % i for i in list({ | ||
"MAP": urllib.parse.quote(self.projectPath), | ||
"SERVICE": "WMS", | ||
"VERSION": "1.1.1", | ||
"REQUEST": "GetPrint", | ||
"TEMPLATE": "layoutA4", | ||
"FORMAT": "png", | ||
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031", | ||
"map0:LAYERS": "Country,Hello", | ||
"CRS": "EPSG:3857", | ||
"IDTEXTBOX": "Updated QGIS composer label" | ||
}.items())]) | ||
|
||
r, h = self._result(self._execute_request(qs)) | ||
self._img_diff_error(r, h, "WMS_GetPrint_LabelUpdated") | ||
|
||
qs = "?" + "&".join(["%s=%s" % i for i in list({ | ||
"MAP": urllib.parse.quote(self.projectPath), | ||
"SERVICE": "WMS", | ||
"VERSION": "1.1.1", | ||
"REQUEST": "GetPrint", | ||
"TEMPLATE": "layoutA4", | ||
"FORMAT": "png", | ||
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031", | ||
"map0:LAYERS": "Country,Hello", | ||
"CRS": "EPSG:3857", | ||
"IDTEXTBOX": "" | ||
}.items())]) | ||
|
||
r, h = self._result(self._execute_request(qs)) | ||
self._img_diff_error(r, h, "WMS_GetPrint_LabelRemoved") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |