Skip to content

Commit c1657ac

Browse files
committedJun 9, 2017
[Server] Add/update tests
1 parent dae8447 commit c1657ac

File tree

11 files changed

+602
-0
lines changed

11 files changed

+602
-0
lines changed
 

‎tests/src/python/test_qgsserver_wms.py

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,63 @@ def test_getLegendGraphics(self):
10271027
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
10281028
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))
10291029

1030+
def test_getLegendGraphics_invalid_parameters(self):
1031+
"""Test that does return an exception"""
1032+
qs = "?" + "&".join(["%s=%s" % i for i in list({
1033+
"MAP": urllib.parse.quote(self.projectPath),
1034+
"SERVICE": "WMS",
1035+
"VERSION": "1.1.1",
1036+
"REQUEST": "GetLegendGraphic",
1037+
"LAYER": "Country,Hello,db_point",
1038+
"LAYERTITLE": "FALSE",
1039+
"FORMAT": "image/png",
1040+
"HEIGHT": "500",
1041+
"WIDTH": "500",
1042+
"RULE": "1",
1043+
"BBOX": "-151.7,-38.9,51.0,78.0",
1044+
"CRS": "EPSG:4326"
1045+
}.items())])
1046+
1047+
r, h = self._result(self._execute_request(qs))
1048+
err = b"BBOX parameter cannot be combined with RULE" in r
1049+
self.assertTrue(err)
1050+
1051+
def test_wms_GetLegendGraphic_LayerSpace(self):
1052+
qs = "?" + "&".join(["%s=%s" % i for i in list({
1053+
"MAP": urllib.parse.quote(self.projectPath),
1054+
"SERVICE": "WMS",
1055+
"VERSION": "1.1.1",
1056+
"REQUEST": "GetLegendGraphic",
1057+
"LAYER": "Country,Hello",
1058+
"FORMAT": "image/png",
1059+
# "HEIGHT": "500",
1060+
# "WIDTH": "500",
1061+
"LAYERSPACE": "50.0",
1062+
"LAYERTITLE": "TRUE",
1063+
"CRS": "EPSG:3857"
1064+
}.items())])
1065+
1066+
r, h = self._result(self._execute_request(qs))
1067+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_LayerSpace")
1068+
1069+
def test_wms_GetLegendGraphic_ShowFeatureCount(self):
1070+
qs = "?" + "&".join(["%s=%s" % i for i in list({
1071+
"MAP": urllib.parse.quote(self.projectPath),
1072+
"SERVICE": "WMS",
1073+
"VERSION": "1.1.1",
1074+
"REQUEST": "GetLegendGraphic",
1075+
"LAYER": "Country,Hello",
1076+
"FORMAT": "image/png",
1077+
# "HEIGHT": "500",
1078+
# "WIDTH": "500",
1079+
"LAYERTITLE": "TRUE",
1080+
"SHOWFEATURECOUNT": "TRUE",
1081+
"CRS": "EPSG:3857"
1082+
}.items())])
1083+
1084+
r, h = self._result(self._execute_request(qs))
1085+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_ShowFeatureCount")
1086+
10301087
def test_getLegendGraphics_layertitle(self):
10311088
"""Test that does not return an exception but an image"""
10321089
parms = {
@@ -1059,6 +1116,66 @@ def test_getLegendGraphics_layertitle(self):
10591116
r, h = self._result(self._execute_request(qs))
10601117
self._img_diff_error(r, h, "WMS_GetLegendGraphic_test_layertitle_false", 250, QSize(15, 15))
10611118

1119+
def test_getLegendGraphics_rulelabel(self):
1120+
"""Test that does not return an exception but an image"""
1121+
parms = {
1122+
'MAP': self.testdata_path + "test_project.qgs",
1123+
'SERVICE': 'WMS',
1124+
'VERSION': '1.3.0',
1125+
'REQUEST': 'GetLegendGraphic',
1126+
'FORMAT': 'image/png',
1127+
'LAYER': u'testlayer%20èé',
1128+
'RULELABEL': 'TRUE',
1129+
}
1130+
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
1131+
r, h = self._result(self._execute_request(qs))
1132+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_test", 250, QSize(15, 15))
1133+
1134+
parms = {
1135+
'MAP': self.testdata_path + "test_project.qgs",
1136+
'SERVICE': 'WMS',
1137+
'VERSION': '1.3.0',
1138+
'REQUEST': 'GetLegendGraphic',
1139+
'FORMAT': 'image/png',
1140+
'LAYER': u'testlayer%20èé',
1141+
'RULELABEL': 'FALSE',
1142+
}
1143+
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
1144+
r, h = self._result(self._execute_request(qs))
1145+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_rulelabel_false", 250, QSize(15, 15))
1146+
1147+
def test_getLegendGraphics_rule(self):
1148+
"""Test that does not return an exception but an image"""
1149+
parms = {
1150+
'MAP': self.testdata_path + "test_project_legend_rule.qgs",
1151+
'SERVICE': 'WMS',
1152+
'VERSION': '1.3.0',
1153+
'REQUEST': 'GetLegendGraphic',
1154+
'FORMAT': 'image/png',
1155+
'LAYER': u'testlayer%20èé',
1156+
'WIDTH': '20',
1157+
'HEIGHT': '20',
1158+
'RULE': 'rule0',
1159+
}
1160+
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
1161+
r, h = self._result(self._execute_request(qs))
1162+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_rule0", 250, QSize(15, 15))
1163+
1164+
parms = {
1165+
'MAP': self.testdata_path + "test_project_legend_rule.qgs",
1166+
'SERVICE': 'WMS',
1167+
'VERSION': '1.3.0',
1168+
'REQUEST': 'GetLegendGraphic',
1169+
'FORMAT': 'image/png',
1170+
'LAYER': u'testlayer%20èé',
1171+
'WIDTH': '20',
1172+
'HEIGHT': '20',
1173+
'RULE': 'rule1',
1174+
}
1175+
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
1176+
r, h = self._result(self._execute_request(qs))
1177+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_rule1", 250, QSize(15, 15))
1178+
10621179
def test_wms_GetLegendGraphic_Basic(self):
10631180
qs = "?" + "&".join(["%s=%s" % i for i in list({
10641181
"MAP": urllib.parse.quote(self.projectPath),
@@ -1202,6 +1319,46 @@ def test_wms_GetLegendGraphic_SymbolSize(self):
12021319
r, h = self._result(self._execute_request(qs))
12031320
self._img_diff_error(r, h, "WMS_GetLegendGraphic_SymbolSize")
12041321

1322+
def test_wms_GetLegendGraphic_LayerFont(self):
1323+
qs = "?" + "&".join(["%s=%s" % i for i in list({
1324+
"MAP": urllib.parse.quote(self.projectPath),
1325+
"SERVICE": "WMS",
1326+
"VERSION": "1.1.1",
1327+
"REQUEST": "GetLegendGraphic",
1328+
"LAYER": "Country,Hello",
1329+
"LAYERTITLE": "TRUE",
1330+
"LAYERFONTBOLD": "TRUE",
1331+
"LAYERFONTITALIC": "TRUE",
1332+
"LAYERFONTSIZE": "30",
1333+
"FORMAT": "image/png",
1334+
"HEIGHT": "500",
1335+
"WIDTH": "500",
1336+
"CRS": "EPSG:3857"
1337+
}.items())])
1338+
1339+
r, h = self._result(self._execute_request(qs))
1340+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_LayerFont")
1341+
1342+
def test_wms_GetLegendGraphic_ItemFont(self):
1343+
qs = "?" + "&".join(["%s=%s" % i for i in list({
1344+
"MAP": urllib.parse.quote(self.projectPath),
1345+
"SERVICE": "WMS",
1346+
"VERSION": "1.1.1",
1347+
"REQUEST": "GetLegendGraphic",
1348+
"LAYER": "Country,Hello",
1349+
"LAYERTITLE": "TRUE",
1350+
"ITEMFONTBOLD": "TRUE",
1351+
"ITEMFONTITALIC": "TRUE",
1352+
"ITEMFONTSIZE": "30",
1353+
"FORMAT": "image/png",
1354+
"HEIGHT": "500",
1355+
"WIDTH": "500",
1356+
"CRS": "EPSG:3857"
1357+
}.items())])
1358+
1359+
r, h = self._result(self._execute_request(qs))
1360+
self._img_diff_error(r, h, "WMS_GetLegendGraphic_ItemFont")
1361+
12051362
def test_wms_GetLegendGraphic_BBox(self):
12061363
qs = "?" + "&".join(["%s=%s" % i for i in list({
12071364
"MAP": urllib.parse.quote(self.projectPath),

‎tests/testdata/qgis_server/test_project_legend_rule.qgs

Lines changed: 445 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.