Skip to content

Commit cdcb5a2

Browse files
committedOct 22, 2018
running autopep8 on file to format correctly
1 parent 97b827e commit cdcb5a2

File tree

1 file changed

+293
-258
lines changed

1 file changed

+293
-258
lines changed
 
Lines changed: 293 additions & 258 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
# -*- coding: utf-8 -*-
2+
from qgis.core import QgsProject
3+
from test_qgsserver_wms import TestQgsServerWMSTestBase
4+
from qgis.PyQt.QtCore import QSize
5+
from qgis.testing import unittest
6+
import json
7+
import xml.etree.ElementTree as ET
8+
import urllib.error
9+
import urllib.parse
10+
import urllib.request
11+
import re
212
"""QGIS Unit tests for QgsServer GetFeatureInfo WMS.
313
414
From build dir, run: ctest -R PyQgsServerWMSGetFeatureInfo -V
@@ -18,25 +28,13 @@
1828

1929
import os
2030

21-
# Needed on Qt 5 so that the serialization of XML is consistent among all executions
31+
# Needed on Qt 5 so that the serialization of XML is consistent among all
32+
# executions
2233
os.environ['QT_HASH_SEED'] = '1'
2334

24-
import re
25-
import urllib.request
26-
import urllib.parse
27-
import urllib.error
28-
29-
import xml.etree.ElementTree as ET
30-
import json
31-
32-
from qgis.testing import unittest
33-
from qgis.PyQt.QtCore import QSize
3435

3536
import osgeo.gdal # NOQA
3637

37-
from test_qgsserver_wms import TestQgsServerWMSTestBase
38-
from qgis.core import QgsProject
39-
4038

4139
class TestQgsServerWMSGetFeatureInfo(TestQgsServerWMSTestBase):
4240

@@ -45,141 +43,141 @@ class TestQgsServerWMSGetFeatureInfo(TestQgsServerWMSTestBase):
4543
def testGetFeatureInfo(self):
4644
# Test getfeatureinfo response xml
4745
self.wms_request_compare('GetFeatureInfo',
48-
'&layers=testlayer%20%C3%A8%C3%A9&styles=&'
49-
+ 'info_format=text%2Fxml&transparent=true&'
50-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
51-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
52-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
46+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
47+
'info_format=text%2Fxml&transparent=true&' +
48+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
49+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
50+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
5351
'wms_getfeatureinfo-text-xml')
5452

5553
self.wms_request_compare('GetFeatureInfo',
56-
'&layers=&styles=&'
57-
+ 'info_format=text%2Fxml&transparent=true&'
58-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
59-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
60-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
54+
'&layers=&styles=&' +
55+
'info_format=text%2Fxml&transparent=true&' +
56+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
57+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
58+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
6159
'wms_getfeatureinfo-text-xml')
6260

6361
# Test getfeatureinfo on non queryable layer
6462
self.wms_request_compare('GetFeatureInfo',
65-
'&layers=testlayer3&styles=&'
66-
+ 'info_format=text%2Fxml&transparent=true&'
67-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
68-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
69-
+ 'query_layers=testlayer3&X=190&Y=320',
63+
'&layers=testlayer3&styles=&' +
64+
'info_format=text%2Fxml&transparent=true&' +
65+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
66+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
67+
'query_layers=testlayer3&X=190&Y=320',
7068
'wms_getfeatureinfo-testlayer3-notqueryable')
7169

7270
# Test getfeatureinfo on group without shortname (no queryable...)
7371
self.wms_request_compare('GetFeatureInfo',
74-
'&layers=groupwithoutshortname&styles=&'
75-
+ 'info_format=text%2Fxml&transparent=true&'
76-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
77-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
78-
+ 'query_layers=groupwithoutshortname&X=190&Y=320',
72+
'&layers=groupwithoutshortname&styles=&' +
73+
'info_format=text%2Fxml&transparent=true&' +
74+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
75+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
76+
'query_layers=groupwithoutshortname&X=190&Y=320',
7977
'wms_getfeatureinfo-groupwithoutshortname-notqueryable')
8078

8179
# Test getfeatureinfo on group with shortname (no queryable...)
8280
self.wms_request_compare('GetFeatureInfo',
83-
'&layers=group_name&styles=&'
84-
+ 'info_format=text%2Fxml&transparent=true&'
85-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
86-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
87-
+ 'query_layers=group_name&X=190&Y=320',
81+
'&layers=group_name&styles=&' +
82+
'info_format=text%2Fxml&transparent=true&' +
83+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
84+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
85+
'query_layers=group_name&X=190&Y=320',
8886
'wms_getfeatureinfo-group_name-notqueryable')
8987

9088
# Test getfeatureinfo response html
9189
self.wms_request_compare('GetFeatureInfo',
92-
'&layers=testlayer%20%C3%A8%C3%A9&styles=&'
93-
+ 'info_format=text%2Fhtml&transparent=true&'
94-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
95-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
96-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
90+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
91+
'info_format=text%2Fhtml&transparent=true&' +
92+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
93+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
94+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
9795
'wms_getfeatureinfo-text-html')
9896

9997
# Test getfeatureinfo response html with geometry
10098
self.wms_request_compare('GetFeatureInfo',
101-
'&layers=testlayer%20%C3%A8%C3%A9&styles=&'
102-
+ 'info_format=text%2Fhtml&transparent=true&'
103-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
104-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
105-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&'
106-
+ 'with_geometry=true',
99+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
100+
'info_format=text%2Fhtml&transparent=true&' +
101+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
102+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
103+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
104+
'with_geometry=true',
107105
'wms_getfeatureinfo-text-html-geometry')
108106

109107
# Test getfeatureinfo response html with maptip
110108
self.wms_request_compare('GetFeatureInfo',
111-
'&layers=testlayer%20%C3%A8%C3%A9&styles=&'
112-
+ 'info_format=text%2Fhtml&transparent=true&'
113-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
114-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
115-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&'
116-
+ 'with_maptip=true',
109+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
110+
'info_format=text%2Fhtml&transparent=true&' +
111+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
112+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
113+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
114+
'with_maptip=true',
117115
'wms_getfeatureinfo-text-html-maptip')
118116

119117
# Test getfeatureinfo response text
120118
self.wms_request_compare('GetFeatureInfo',
121-
'&layers=testlayer%20%C3%A8%C3%A9&styles=&'
122-
+ 'transparent=true&'
123-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
124-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
125-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&'
126-
+ 'info_format=text/plain',
119+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
120+
'transparent=true&' +
121+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
122+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
123+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
124+
'info_format=text/plain',
127125
'wms_getfeatureinfo-text-plain')
128126

129127
# Test getfeatureinfo default info_format
130128
self.wms_request_compare('GetFeatureInfo',
131-
'&layers=testlayer%20%C3%A8%C3%A9&styles=&'
132-
+ 'transparent=true&'
133-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
134-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
135-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
129+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
130+
'transparent=true&' +
131+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
132+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
133+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
136134
'wms_getfeatureinfo-text-plain')
137135

138136
# Test getfeatureinfo invalid info_format
139137
self.wms_request_compare('GetFeatureInfo',
140-
'&layers=testlayer%20%C3%A8%C3%A9&styles=&'
141-
+ 'transparent=true&'
142-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
143-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
144-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&'
145-
+ 'info_format=InvalidFormat',
138+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
139+
'transparent=true&' +
140+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
141+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
142+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
143+
'info_format=InvalidFormat',
146144
'wms_getfeatureinfo-invalid-format')
147145

148146
# Test feature info request with filter geometry
149147
self.wms_request_compare('GetFeatureInfo',
150-
'&layers=testlayer%20%C3%A8%C3%A9&'
151-
+ 'INFO_FORMAT=text%2Fxml&'
152-
+ 'width=600&height=400&srs=EPSG%3A4326&'
153-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&'
154-
+ 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))',
148+
'&layers=testlayer%20%C3%A8%C3%A9&' +
149+
'INFO_FORMAT=text%2Fxml&' +
150+
'width=600&height=400&srs=EPSG%3A4326&' +
151+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
152+
'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))',
155153
'wms_getfeatureinfo_geometry_filter')
156154

157155
# Test feature info request with filter geometry in non-layer CRS
158156
self.wms_request_compare('GetFeatureInfo',
159-
'&layers=testlayer%20%C3%A8%C3%A9&'
160-
+ 'INFO_FORMAT=text%2Fxml&'
161-
+ 'width=600&height=400&srs=EPSG%3A3857&'
162-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&'
163-
+ 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON ((913213.6839952 5606021.5399693, 913215.6988780 5606021.5399693, 913215.6988780 5606015.09643322, 913213.6839952 5606015.0964332, 913213.6839952 5606021.5399693))',
157+
'&layers=testlayer%20%C3%A8%C3%A9&' +
158+
'INFO_FORMAT=text%2Fxml&' +
159+
'width=600&height=400&srs=EPSG%3A3857&' +
160+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
161+
'FEATURE_COUNT=10&FILTER_GEOM=POLYGON ((913213.6839952 5606021.5399693, 913215.6988780 5606021.5399693, 913215.6988780 5606015.09643322, 913213.6839952 5606015.0964332, 913213.6839952 5606021.5399693))',
164162
'wms_getfeatureinfo_geometry_filter_3857')
165163

166164
# Test feature info request with invalid query_layer
167165
self.wms_request_compare('GetFeatureInfo',
168-
'&layers=testlayer%20%C3%A8%C3%A9&'
169-
+ 'INFO_FORMAT=text%2Fxml&'
170-
+ 'width=600&height=400&srs=EPSG%3A3857&'
171-
+ 'query_layers=InvalidLayer&'
172-
+ 'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))',
166+
'&layers=testlayer%20%C3%A8%C3%A9&' +
167+
'INFO_FORMAT=text%2Fxml&' +
168+
'width=600&height=400&srs=EPSG%3A3857&' +
169+
'query_layers=InvalidLayer&' +
170+
'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))',
173171
'wms_getfeatureinfo_invalid_query_layers')
174172

175173
# Test feature info request with '+' instead of ' ' in layers and
176174
# query_layers parameters
177175
self.wms_request_compare('GetFeatureInfo',
178-
'&layers=testlayer+%C3%A8%C3%A9&styles=&'
179-
+ 'info_format=text%2Fxml&transparent=true&'
180-
+ 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C'
181-
+ '5606005.488876367%2C913235.426296057%2C5606035.347090538&'
182-
+ 'query_layers=testlayer+%C3%A8%C3%A9&X=190&Y=320',
176+
'&layers=testlayer+%C3%A8%C3%A9&styles=&' +
177+
'info_format=text%2Fxml&transparent=true&' +
178+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
179+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
180+
'query_layers=testlayer+%C3%A8%C3%A9&X=190&Y=320',
183181
'wms_getfeatureinfo-text-xml')
184182

185183
# layer1 is a clone of layer0 but with a scale visibility. Thus,
@@ -188,76 +186,78 @@ def testGetFeatureInfo(self):
188186
# the feature for layer1 would have been in the response too.
189187
mypath = self.testdata_path + "test_project_scalevisibility.qgs"
190188
self.wms_request_compare('GetFeatureInfo',
191-
'&layers=layer0,layer1&styles=&'
192-
+ 'VERSION=1.1.0&'
193-
+ 'info_format=text%2Fxml&'
194-
+ 'width=500&height=500&srs=EPSG%3A4326'
195-
+ '&bbox=8.1976,44.8998,8.2100,44.9027&'
196-
+ 'query_layers=layer0,layer1&X=235&Y=243',
189+
'&layers=layer0,layer1&styles=&' +
190+
'VERSION=1.1.0&' +
191+
'info_format=text%2Fxml&' +
192+
'width=500&height=500&srs=EPSG%3A4326' +
193+
'&bbox=8.1976,44.8998,8.2100,44.9027&' +
194+
'query_layers=layer0,layer1&X=235&Y=243',
197195
'wms_getfeatureinfo_notvisible',
198196
'test_project_scalevisibility.qgs')
199197

200-
# Test GetFeatureInfo resolves "value map" widget values but also Server usage of qgs and gpkg file
198+
# Test GetFeatureInfo resolves "value map" widget values but also
199+
# Server usage of qgs and gpkg file
201200
mypath = self.testdata_path + "test_project_values.qgz"
202201
self.wms_request_compare('GetFeatureInfo',
203-
'&layers=layer0&styles=&'
204-
+ 'VERSION=1.3.0&'
205-
+ 'info_format=text%2Fxml&'
206-
+ 'width=926&height=787&srs=EPSG%3A4326'
207-
+ '&bbox=912217,5605059,914099,5606652'
208-
+ '&CRS=EPSG:3857'
209-
+ '&FEATURE_COUNT=10'
210-
+ '&QUERY_LAYERS=layer0&I=487&J=308',
202+
'&layers=layer0&styles=&' +
203+
'VERSION=1.3.0&' +
204+
'info_format=text%2Fxml&' +
205+
'width=926&height=787&srs=EPSG%3A4326' +
206+
'&bbox=912217,5605059,914099,5606652' +
207+
'&CRS=EPSG:3857' +
208+
'&FEATURE_COUNT=10' +
209+
'&QUERY_LAYERS=layer0&I=487&J=308',
211210
'wms_getfeatureinfo-values0-text-xml',
212211
'test_project_values.qgz')
213212

214213
def testGetFeatureInfoValueRelation(self):
215214
"""Test GetFeatureInfo resolves "value relation" widget values. regression 18518"""
216215
mypath = self.testdata_path + "test_project_values.qgz"
217216
self.wms_request_compare('GetFeatureInfo',
218-
'&layers=layer1&styles=&'
219-
+ 'VERSION=1.3.0&'
220-
+ 'info_format=text%2Fxml&'
221-
+ 'width=926&height=787&srs=EPSG%3A4326'
222-
+ '&bbox=912217,5605059,914099,5606652'
223-
+ '&CRS=EPSG:3857'
224-
+ '&FEATURE_COUNT=10'
225-
+ '&WITH_GEOMETRY=True'
226-
+ '&QUERY_LAYERS=layer1&I=487&J=308',
217+
'&layers=layer1&styles=&' +
218+
'VERSION=1.3.0&' +
219+
'info_format=text%2Fxml&' +
220+
'width=926&height=787&srs=EPSG%3A4326' +
221+
'&bbox=912217,5605059,914099,5606652' +
222+
'&CRS=EPSG:3857' +
223+
'&FEATURE_COUNT=10' +
224+
'&WITH_GEOMETRY=True' +
225+
'&QUERY_LAYERS=layer1&I=487&J=308',
227226
'wms_getfeatureinfo-values1-text-xml',
228227
'test_project_values.qgz')
229228

230229
def testGetFeatureInfoValueRelationArray(self):
231230
"""Test GetFeatureInfo on "value relation" widget with array field (multiple selections)"""
232231
mypath = self.testdata_path + "test_project_values.qgz"
233232
self.wms_request_compare('GetFeatureInfo',
234-
'&layers=layer3&styles=&'
235-
+ 'VERSION=1.3.0&'
236-
+ 'info_format=text%2Fxml&'
237-
+ 'width=926&height=787&srs=EPSG%3A4326'
238-
+ '&bbox=912217,5605059,914099,5606652'
239-
+ '&CRS=EPSG:3857'
240-
+ '&FEATURE_COUNT=10'
241-
+ '&WITH_GEOMETRY=True'
242-
+ '&QUERY_LAYERS=layer3&I=487&J=308',
233+
'&layers=layer3&styles=&' +
234+
'VERSION=1.3.0&' +
235+
'info_format=text%2Fxml&' +
236+
'width=926&height=787&srs=EPSG%3A4326' +
237+
'&bbox=912217,5605059,914099,5606652' +
238+
'&CRS=EPSG:3857' +
239+
'&FEATURE_COUNT=10' +
240+
'&WITH_GEOMETRY=True' +
241+
'&QUERY_LAYERS=layer3&I=487&J=308',
243242
'wms_getfeatureinfo-values3-text-xml',
244243
'test_project_values.qgz')
245244

246-
# TODO make GetFeatureInfo show what's in the display expression and enable test
245+
# TODO make GetFeatureInfo show what's in the display expression and
246+
# enable test
247247
@unittest.expectedFailure
248248
def testGetFeatureInfoRelationReference(self):
249249
"""Test GetFeatureInfo solves "relation reference" widget "display expression" values"""
250250
mypath = self.testdata_path + "test_project_values.qgz"
251251
self.wms_request_compare('GetFeatureInfo',
252-
'&layers=layer2&styles=&'
253-
+ 'VERSION=1.3.0&'
254-
+ 'info_format=text%2Fxml&'
255-
+ 'width=926&height=787&srs=EPSG%3A4326'
256-
+ '&bbox=912217,5605059,914099,5606652'
257-
+ '&CRS=EPSG:3857'
258-
+ '&FEATURE_COUNT=10'
259-
+ '&WITH_GEOMETRY=True'
260-
+ '&QUERY_LAYERS=layer2&I=487&J=308',
252+
'&layers=layer2&styles=&' +
253+
'VERSION=1.3.0&' +
254+
'info_format=text%2Fxml&' +
255+
'width=926&height=787&srs=EPSG%3A4326' +
256+
'&bbox=912217,5605059,914099,5606652' +
257+
'&CRS=EPSG:3857' +
258+
'&FEATURE_COUNT=10' +
259+
'&WITH_GEOMETRY=True' +
260+
'&QUERY_LAYERS=layer2&I=487&J=308',
261261
'wms_getfeatureinfo-values2-text-xml',
262262
'test_project_values.qgz')
263263

@@ -266,11 +266,12 @@ def testGetFeatureInfoFilterGPKG(self):
266266
# Regression for #8656 Test getfeatureinfo response xml with gpkg datasource
267267
# Mind the gap! (the space in the FILTER expression)
268268
self.wms_request_compare('GetFeatureInfo',
269-
'&layers=testlayer%20%C3%A8%C3%A9&'
270-
+ 'INFO_FORMAT=text%2Fxml&'
271-
+ 'width=600&height=400&srs=EPSG%3A3857&'
272-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&'
273-
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\''),
269+
'&layers=testlayer%20%C3%A8%C3%A9&' +
270+
'INFO_FORMAT=text%2Fxml&' +
271+
'width=600&height=400&srs=EPSG%3A3857&' +
272+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
273+
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
274+
urllib.parse.quote(':"NAME" = \'two\''),
274275
'wms_getfeatureinfo_filter_gpkg',
275276
'test_project.qgz')
276277

@@ -280,194 +281,228 @@ def testGetFeatureInfoFilter(self):
280281
# Regression for #8656
281282
# Mind the gap! (the space in the FILTER expression)
282283
self.wms_request_compare('GetFeatureInfo',
283-
'&layers=testlayer%20%C3%A8%C3%A9&'
284-
+ 'INFO_FORMAT=text%2Fxml&'
285-
+ 'width=600&height=400&srs=EPSG%3A3857&'
286-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&'
287-
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\''),
284+
'&layers=testlayer%20%C3%A8%C3%A9&' +
285+
'INFO_FORMAT=text%2Fxml&' +
286+
'width=600&height=400&srs=EPSG%3A3857&' +
287+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
288+
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
289+
urllib.parse.quote(':"NAME" = \'two\''),
288290
'wms_getfeatureinfo_filter')
289291

290292
# Test a filter with NO condition results
291293
self.wms_request_compare('GetFeatureInfo',
292-
'&layers=testlayer%20%C3%A8%C3%A9&'
293-
+ 'INFO_FORMAT=text%2Fxml&'
294-
+ 'width=600&height=400&srs=EPSG%3A3857&'
295-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&'
296-
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\' AND "utf8nameè" = \'no-results\''),
294+
'&layers=testlayer%20%C3%A8%C3%A9&' +
295+
'INFO_FORMAT=text%2Fxml&' +
296+
'width=600&height=400&srs=EPSG%3A3857&' +
297+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
298+
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
299+
urllib.parse.quote(
300+
':"NAME" = \'two\' AND "utf8nameè" = \'no-results\''),
297301
'wms_getfeatureinfo_filter_no_results')
298302

299303
# Test a filter with OR condition results
300304
self.wms_request_compare('GetFeatureInfo',
301-
'&layers=testlayer%20%C3%A8%C3%A9&'
302-
+ 'INFO_FORMAT=text%2Fxml&'
303-
+ 'width=600&height=400&srs=EPSG%3A3857&'
304-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&'
305-
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\' OR "NAME" = \'three\''),
305+
'&layers=testlayer%20%C3%A8%C3%A9&' +
306+
'INFO_FORMAT=text%2Fxml&' +
307+
'width=600&height=400&srs=EPSG%3A3857&' +
308+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
309+
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
310+
urllib.parse.quote(
311+
':"NAME" = \'two\' OR "NAME" = \'three\''),
306312
'wms_getfeatureinfo_filter_or')
307313

308314
# Test a filter with OR condition and UTF results
309315
# Note that the layer name that contains utf-8 chars cannot be
310316
# to upper case.
311317
self.wms_request_compare('GetFeatureInfo',
312-
'&layers=testlayer%20%C3%A8%C3%A9&'
313-
+ 'INFO_FORMAT=text%2Fxml&'
314-
+ 'width=600&height=400&srs=EPSG%3A3857&'
315-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&'
316-
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\' OR "utf8nameè" = \'three èé↓\''),
318+
'&layers=testlayer%20%C3%A8%C3%A9&' +
319+
'INFO_FORMAT=text%2Fxml&' +
320+
'width=600&height=400&srs=EPSG%3A3857&' +
321+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
322+
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
323+
urllib.parse.quote(
324+
':"NAME" = \'two\' OR "utf8nameè" = \'three èé↓\''),
317325
'wms_getfeatureinfo_filter_or_utf8')
318326

319-
# Regression #18292 Server GetFeatureInfo FILTER search fails when WIDTH, HEIGHT are not specified
327+
# Regression #18292 Server GetFeatureInfo FILTER search fails when
328+
# WIDTH, HEIGHT are not specified
320329
self.wms_request_compare('GetFeatureInfo',
321-
'&layers=testlayer%20%C3%A8%C3%A9&'
322-
+ 'INFO_FORMAT=text%2Fxml&'
323-
+ 'srs=EPSG%3A3857&'
324-
+ 'query_layers=testlayer%20%C3%A8%C3%A9&'
325-
+ 'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\''),
330+
'&layers=testlayer%20%C3%A8%C3%A9&' +
331+
'INFO_FORMAT=text%2Fxml&' +
332+
'srs=EPSG%3A3857&' +
333+
'query_layers=testlayer%20%C3%A8%C3%A9&' +
334+
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' +
335+
urllib.parse.quote(':"NAME" = \'two\''),
326336
'wms_getfeatureinfo_filter_no_width')
327337

328338
def testGetFeatureInfoTolerance(self):
329339
self.wms_request_compare('GetFeatureInfo',
330-
'&layers=layer3&styles=&'
331-
+ 'VERSION=1.3.0&'
332-
+ 'info_format=text%2Fxml&'
333-
+ 'width=400&height=200'
334-
+ '&bbox=913119.2,5605988.9,913316.0,5606047.4'
335-
+ '&CRS=EPSG:3857'
336-
+ '&FEATURE_COUNT=10'
337-
+ '&WITH_GEOMETRY=False'
338-
+ '&QUERY_LAYERS=layer3&I=193&J=100'
339-
+ '&FI_POINT_TOLERANCE=0',
340+
'&layers=layer3&styles=&' +
341+
'VERSION=1.3.0&' +
342+
'info_format=text%2Fxml&' +
343+
'width=400&height=200' +
344+
'&bbox=913119.2,5605988.9,913316.0,5606047.4' +
345+
'&CRS=EPSG:3857' +
346+
'&FEATURE_COUNT=10' +
347+
'&WITH_GEOMETRY=False' +
348+
'&QUERY_LAYERS=layer3&I=193&J=100' +
349+
'&FI_POINT_TOLERANCE=0',
340350
'wms_getfeatureinfo_point_tolerance_0_text_xml',
341351
'test_project_values.qgz')
342352

343353
self.wms_request_compare('GetFeatureInfo',
344-
'&layers=layer3&styles=&'
345-
+ 'VERSION=1.3.0&'
346-
+ 'info_format=text%2Fxml&'
347-
+ 'width=400&height=200'
348-
+ '&bbox=913119.2,5605988.9,913316.0,5606047.4'
349-
+ '&CRS=EPSG:3857'
350-
+ '&FEATURE_COUNT=10'
351-
+ '&WITH_GEOMETRY=False'
352-
+ '&QUERY_LAYERS=layer3&I=193&J=100'
353-
+ '&FI_POINT_TOLERANCE=20',
354+
'&layers=layer3&styles=&' +
355+
'VERSION=1.3.0&' +
356+
'info_format=text%2Fxml&' +
357+
'width=400&height=200' +
358+
'&bbox=913119.2,5605988.9,913316.0,5606047.4' +
359+
'&CRS=EPSG:3857' +
360+
'&FEATURE_COUNT=10' +
361+
'&WITH_GEOMETRY=False' +
362+
'&QUERY_LAYERS=layer3&I=193&J=100' +
363+
'&FI_POINT_TOLERANCE=20',
354364
'wms_getfeatureinfo_point_tolerance_20_text_xml',
355365
'test_project_values.qgz')
356366

357367
self.wms_request_compare('GetFeatureInfo',
358-
'&layers=ls2d&styles=&'
359-
+ 'VERSION=1.3.0&'
360-
+ 'info_format=text%2Fxml&'
361-
+ 'width=400&height=200'
362-
+ '&bbox=-50396.4,-2783.0,161715.8,114108.6'
363-
+ '&CRS=EPSG:3857'
364-
+ '&FEATURE_COUNT=10'
365-
+ '&WITH_GEOMETRY=False'
366-
+ '&QUERY_LAYERS=ls2d&I=153&J=147'
367-
+ '&FI_LINE_TOLERANCE=0',
368+
'&layers=ls2d&styles=&' +
369+
'VERSION=1.3.0&' +
370+
'info_format=text%2Fxml&' +
371+
'width=400&height=200' +
372+
'&bbox=-50396.4,-2783.0,161715.8,114108.6' +
373+
'&CRS=EPSG:3857' +
374+
'&FEATURE_COUNT=10' +
375+
'&WITH_GEOMETRY=False' +
376+
'&QUERY_LAYERS=ls2d&I=153&J=147' +
377+
'&FI_LINE_TOLERANCE=0',
368378
'wms_getfeatureinfo_line_tolerance_0_text_xml',
369379
'test_project_values.qgz')
370380

371381
self.wms_request_compare('GetFeatureInfo',
372-
'&layers=ls2d&styles=&'
373-
+ 'VERSION=1.3.0&'
374-
+ 'info_format=text%2Fxml&'
375-
+ 'width=400&height=200'
376-
+ '&bbox=-50396.4,-2783.0,161715.8,114108.6'
377-
+ '&CRS=EPSG:3857'
378-
+ '&FEATURE_COUNT=10'
379-
+ '&WITH_GEOMETRY=False'
380-
+ '&QUERY_LAYERS=ls2d&I=153&J=147'
381-
+ '&FI_LINE_TOLERANCE=20',
382+
'&layers=ls2d&styles=&' +
383+
'VERSION=1.3.0&' +
384+
'info_format=text%2Fxml&' +
385+
'width=400&height=200' +
386+
'&bbox=-50396.4,-2783.0,161715.8,114108.6' +
387+
'&CRS=EPSG:3857' +
388+
'&FEATURE_COUNT=10' +
389+
'&WITH_GEOMETRY=False' +
390+
'&QUERY_LAYERS=ls2d&I=153&J=147' +
391+
'&FI_LINE_TOLERANCE=20',
382392
'wms_getfeatureinfo_line_tolerance_20_text_xml',
383393
'test_project_values.qgz')
384394

385395
self.wms_request_compare('GetFeatureInfo',
386-
'&layers=p2d&styles=&'
387-
+ 'VERSION=1.3.0&'
388-
+ 'info_format=text%2Fxml&'
389-
+ 'width=400&height=200'
390-
+ '&bbox=-135832.0,-66482.4,240321.9,167300.4'
391-
+ '&CRS=EPSG:3857'
392-
+ '&FEATURE_COUNT=10'
393-
+ '&WITH_GEOMETRY=False'
394-
+ '&QUERY_LAYERS=p2d&I=206&J=144'
395-
+ '&FI_POLYGON_TOLERANCE=0',
396+
'&layers=p2d&styles=&' +
397+
'VERSION=1.3.0&' +
398+
'info_format=text%2Fxml&' +
399+
'width=400&height=200' +
400+
'&bbox=-135832.0,-66482.4,240321.9,167300.4' +
401+
'&CRS=EPSG:3857' +
402+
'&FEATURE_COUNT=10' +
403+
'&WITH_GEOMETRY=False' +
404+
'&QUERY_LAYERS=p2d&I=206&J=144' +
405+
'&FI_POLYGON_TOLERANCE=0',
396406
'wms_getfeatureinfo_polygon_tolerance_0_text_xml',
397407
'test_project_values.qgz')
398408

399409
self.wms_request_compare('GetFeatureInfo',
400-
'&layers=p2d&styles=&'
401-
+ 'VERSION=1.3.0&'
402-
+ 'info_format=text%2Fxml&'
403-
+ 'width=400&height=200'
404-
+ '&bbox=-135832.0,-66482.4,240321.9,167300.4'
405-
+ '&CRS=EPSG:3857'
406-
+ '&FEATURE_COUNT=10'
407-
+ '&WITH_GEOMETRY=False'
408-
+ '&QUERY_LAYERS=p2d&I=206&J=144'
409-
+ '&FI_POLYGON_TOLERANCE=20',
410+
'&layers=p2d&styles=&' +
411+
'VERSION=1.3.0&' +
412+
'info_format=text%2Fxml&' +
413+
'width=400&height=200' +
414+
'&bbox=-135832.0,-66482.4,240321.9,167300.4' +
415+
'&CRS=EPSG:3857' +
416+
'&FEATURE_COUNT=10' +
417+
'&WITH_GEOMETRY=False' +
418+
'&QUERY_LAYERS=p2d&I=206&J=144' +
419+
'&FI_POLYGON_TOLERANCE=20',
410420
'wms_getfeatureinfo_polygon_tolerance_20_text_xml',
411421
'test_project_values.qgz')
412422

413423
def testGetFeatureInfoPostgresTypes(self):
414-
#compare json list output with file
415-
self.wms_request_compare('GetFeatureInfo',
416-
'&layers=json'
417-
+ '&info_format=text%2Fxml'
418-
+ '&srs=EPSG%3A3857'
419-
+ '&QUERY_LAYERS=json'
420-
+ '&FILTER=json' + urllib.parse.quote(':"pk" = 1'),
424+
# compare json list output with file
425+
self.wms_request_compare('GetFeatureInfo',
426+
'&layers=json' +
427+
'&info_format=text%2Fxml' +
428+
'&srs=EPSG%3A3857' +
429+
'&QUERY_LAYERS=json' +
430+
'&FILTER=json' +
431+
urllib.parse.quote(':"pk" = 1'),
421432
'get_postgres_types_json_list',
422433
'test_project_postgres_types.qgs')
423434

424-
#compare dict output with file
435+
# compare dict output with file
425436
self.wms_request_compare('GetFeatureInfo',
426-
'&layers=json'
427-
+ '&info_format=text%2Fxml'
428-
+ '&srs=EPSG%3A3857'
429-
+ '&QUERY_LAYERS=json'
430-
+ '&FILTER=json' + urllib.parse.quote(':"pk" = 2'),
437+
'&layers=json' +
438+
'&info_format=text%2Fxml' +
439+
'&srs=EPSG%3A3857' +
440+
'&QUERY_LAYERS=json' +
441+
'&FILTER=json' +
442+
urllib.parse.quote(':"pk" = 2'),
431443
'get_postgres_types_json_dict',
432444
'test_project_postgres_types.qgs')
433445

434-
#compare decoded json field list
446+
# compare decoded json field list
435447
response_header, response_body, query_string = self.wms_request('GetFeatureInfo',
436-
'&layers=json'
437-
+ '&info_format=text%2Fxml'
438-
+ '&srs=EPSG%3A3857'
439-
+ '&QUERY_LAYERS=json'
440-
+ '&FILTER=json' + urllib.parse.quote(':"pk" = 1'),
448+
'&layers=json' +
449+
'&info_format=text%2Fxml' +
450+
'&srs=EPSG%3A3857' +
451+
'&QUERY_LAYERS=json' +
452+
'&FILTER=json' +
453+
urllib.parse.quote(
454+
':"pk" = 1'),
441455
'test_project_postgres_types.qgs')
442456
root = ET.fromstring(response_body)
443457
for attribute in root.iter('Attribute'):
444458
if attribute.get('name') == 'jvalue':
445459
self.assertIsInstance(json.loads(attribute.get('value')), list)
446460
self.assertEqual(json.loads(attribute.get('value')), [1, 2, 3])
447-
self.assertEqual(json.loads(attribute.get('value')), [1.0, 2.0, 3.0])
461+
self.assertEqual(
462+
json.loads(
463+
attribute.get('value')), [
464+
1.0, 2.0, 3.0])
448465
if attribute.get('name') == 'jbvalue':
449466
self.assertIsInstance(json.loads(attribute.get('value')), list)
450467
self.assertEqual(json.loads(attribute.get('value')), [4, 5, 6])
451-
self.assertEqual(json.loads(attribute.get('value')), [4.0, 5.0, 6.0])
468+
self.assertEqual(
469+
json.loads(
470+
attribute.get('value')), [
471+
4.0, 5.0, 6.0])
452472

453-
#compare decoded json field dict
473+
# compare decoded json field dict
454474
response_header, response_body, query_string = self.wms_request('GetFeatureInfo',
455-
'&layers=json'
456-
+ '&info_format=text%2Fxml'
457-
+ '&srs=EPSG%3A3857'
458-
+ '&QUERY_LAYERS=json'
459-
+ '&FILTER=json' + urllib.parse.quote(':"pk" = 2'),
475+
'&layers=json' +
476+
'&info_format=text%2Fxml' +
477+
'&srs=EPSG%3A3857' +
478+
'&QUERY_LAYERS=json' +
479+
'&FILTER=json' +
480+
urllib.parse.quote(
481+
':"pk" = 2'),
460482
'test_project_postgres_types.qgs')
461483
root = ET.fromstring(response_body)
462484
for attribute in root.iter('Attribute'):
463485
if attribute.get('name') == 'jvalue':
464486
self.assertIsInstance(json.loads(attribute.get('value')), dict)
465-
self.assertEqual(json.loads(attribute.get('value')), {'a': 1, 'b': 2})
466-
self.assertEqual(json.loads(attribute.get('value')), {'a': 1.0, 'b': 2.0})
487+
self.assertEqual(
488+
json.loads(
489+
attribute.get('value')), {
490+
'a': 1, 'b': 2})
491+
self.assertEqual(
492+
json.loads(
493+
attribute.get('value')), {
494+
'a': 1.0, 'b': 2.0})
467495
if attribute.get('name') == 'jbvalue':
468496
self.assertIsInstance(json.loads(attribute.get('value')), dict)
469-
self.assertEqual(json.loads(attribute.get('value')), {'c': 4, 'd': 5})
470-
self.assertEqual(json.loads(attribute.get('value')), {'c': 4.0, 'd': 5.0})
497+
self.assertEqual(
498+
json.loads(
499+
attribute.get('value')), {
500+
'c': 4, 'd': 5})
501+
self.assertEqual(
502+
json.loads(
503+
attribute.get('value')), {
504+
'c': 4.0, 'd': 5.0})
505+
471506

472507
if __name__ == '__main__':
473508
unittest.main()

0 commit comments

Comments
 (0)
Please sign in to comment.