Skip to content

Commit f2304c1

Browse files
authoredMay 8, 2018
Merge pull request #6764 from tudorbarascu/featureinfo_values
server tests for GetFeatureinfo different widget values
2 parents 83218c9 + 90355f0 commit f2304c1

8 files changed

+1837
-2
lines changed
 

‎tests/src/python/test_qgsserver_wms_getfeatureinfo.py

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def testGetFeatureInfo(self):
6666
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
6767
'wms_getfeatureinfo-text-html')
6868

69-
#Test getfeatureinfo response html with geometry
69+
# Test getfeatureinfo response html with geometry
7070
self.wms_request_compare('GetFeatureInfo',
7171
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
7272
'info_format=text%2Fhtml&transparent=true&' +
@@ -76,7 +76,7 @@ def testGetFeatureInfo(self):
7676
'with_geometry=true',
7777
'wms_getfeatureinfo-text-html-geometry')
7878

79-
#Test getfeatureinfo response html with maptip
79+
# Test getfeatureinfo response html with maptip
8080
self.wms_request_compare('GetFeatureInfo',
8181
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
8282
'info_format=text%2Fhtml&transparent=true&' +
@@ -167,6 +167,74 @@ def testGetFeatureInfo(self):
167167
'wms_getfeatureinfo_notvisible',
168168
'test_project_scalevisibility.qgs')
169169

170+
# Test GetFeatureInfo resolves "value map" widget values
171+
mypath = self.testdata_path + "test_project_values.qgs"
172+
self.wms_request_compare('GetFeatureInfo',
173+
'&layers=layer0&styles=&' +
174+
'VERSION=1.3.0&' +
175+
'info_format=text%2Fxml&' +
176+
'width=926&height=787&srs=EPSG%3A4326' +
177+
'&bbox=912217,5605059,914099,5606652' +
178+
'&CRS=EPSG:3857' +
179+
'&FEATURE_COUNT=10' +
180+
'&QUERY_LAYERS=layer0&I=487&J=308',
181+
'wms_getfeatureinfo-values1-text-xml',
182+
'test_project_values.qgs')
183+
184+
# TODO fix regression in QGIS 3 as the widget values don't get solved and enable test
185+
@unittest.expectedFailure
186+
def testGetFeatureInfoValueRelation(self):
187+
"""Test GetFeatureInfo resolves "value relation" widget values"""
188+
mypath = self.testdata_path + "test_project_values.qgs"
189+
self.wms_request_compare('GetFeatureInfo',
190+
'&layers=layer1&styles=&' +
191+
'VERSION=1.3.0&' +
192+
'info_format=text%2Fxml&' +
193+
'width=926&height=787&srs=EPSG%3A4326' +
194+
'&bbox=912217,5605059,914099,5606652' +
195+
'&CRS=EPSG:3857' +
196+
'&FEATURE_COUNT=10' +
197+
'&WITH_GEOMETRY=True' +
198+
'&QUERY_LAYERS=layer1&I=487&J=308',
199+
'wms_getfeatureinfo-values1-text-xml',
200+
'test_project_values.qgs')
201+
202+
# TODO make GetFeatureInfo show the dictionary values and enable test
203+
@unittest.expectedFailure
204+
def testGetFeatureInfoValueRelationArray(self):
205+
"""Test GetFeatureInfo on "value relation" widget with array field (multiple selections)"""
206+
mypath = self.testdata_path + "test_project_values.qgs"
207+
self.wms_request_compare('GetFeatureInfo',
208+
'&layers=layer3&styles=&' +
209+
'VERSION=1.3.0&' +
210+
'info_format=text%2Fxml&' +
211+
'width=926&height=787&srs=EPSG%3A4326' +
212+
'&bbox=912217,5605059,914099,5606652' +
213+
'&CRS=EPSG:3857' +
214+
'&FEATURE_COUNT=10' +
215+
'&WITH_GEOMETRY=True' +
216+
'&QUERY_LAYERS=layer3&I=487&J=308',
217+
'wms_getfeatureinfo-values3-text-xml',
218+
'test_project_values.qgs')
219+
220+
# TODO make GetFeatureInfo show what's in the display expression and enable test
221+
@unittest.expectedFailure
222+
def testGetFeatureInfoRelationReference(self):
223+
"""Test GetFeatureInfo solves "relation reference" widget "display expression" values"""
224+
mypath = self.testdata_path + "test_project_values.qgs"
225+
self.wms_request_compare('GetFeatureInfo',
226+
'&layers=layer2&styles=&' +
227+
'VERSION=1.3.0&' +
228+
'info_format=text%2Fxml&' +
229+
'width=926&height=787&srs=EPSG%3A4326' +
230+
'&bbox=912217,5605059,914099,5606652' +
231+
'&CRS=EPSG:3857' +
232+
'&FEATURE_COUNT=10' +
233+
'&WITH_GEOMETRY=True' +
234+
'&QUERY_LAYERS=layer2&I=487&J=308',
235+
'wms_getfeatureinfo-values2-text-xml',
236+
'test_project_values.qgs')
237+
170238
def testGetFeatureInfoFilter(self):
171239
# Test getfeatureinfo response xml
172240

‎tests/testdata/provider/testdata_pg.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ INSERT INTO qgis_test."some_poly_data" (pk, geom) VALUES
7676
(4, NULL)
7777
;
7878

79+
80+
CREATE TABLE qgis_test.array_tbl (id serial PRIMARY KEY, location int[], geom geometry(Point,3857));
81+
82+
INSERT INTO qgis_test.array_tbl (location, geom) VALUES ('{1, 2, 3}', 'srid=3857;Point(913209.0358 5606025.2373)'::geometry);
83+
INSERT INTO qgis_test.array_tbl (location, geom) VALUES ('{}', 'srid=3857;Point(913214.6741 5606017.8743)'::geometry);
84+
INSERT INTO qgis_test.array_tbl (geom) VALUES ('srid=3857;Point(913204.9128 5606011.4565)'::geometry);
85+
86+
7987
-- Provider check with compound key
8088

8189
CREATE TABLE qgis_test."someDataCompound" (
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
id,short_ro,_displayname_en,diameter,pressure_nominal
2+
1,PE,PE 1000 PN6,1000,6
3+
2,PE,PE,,
4+
3,PE,PE 1000 PN8,1000,8

‎tests/testdata/qgis_server/test_project_values.qgs

Lines changed: 1675 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
id,value_id,reverse,reverse_val
2+
1,Id no. 1 value,one,one_value
3+
2,Id no. 2 value,two,two_val
4+
3,Id número 3 value,three,three_val
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="layer0">
6+
<Feature id="0">
7+
<Attribute value="1" name="id"/>
8+
<Attribute value="one" name="name"/>
9+
<Attribute value="First Value" name="utf8nameè"/>
10+
</Feature>
11+
<Feature id="1">
12+
<Attribute value="2" name="id"/>
13+
<Attribute value="two" name="name"/>
14+
<Attribute value="Second Value" name="utf8nameè"/>
15+
</Feature>
16+
<Feature id="2">
17+
<Attribute value="3" name="id"/>
18+
<Attribute value="three" name="name"/>
19+
<Attribute value="Third èé↓" name="utf8nameè"/>
20+
</Feature>
21+
</Layer>
22+
</GetFeatureInfoResponse>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="layer2">
6+
<Feature id="0">
7+
<Attribute value="value PE 1000 PN6" name="id"/>
8+
<Attribute value="one" name="name"/>
9+
<Attribute value="one èé" name="utf8nameè"/>
10+
<BoundingBox maxy="5606025.2373" maxx="913209.0358" miny="5606025.2373" CRS="EPSG:3857" minx="913209.0358"/>
11+
<Attribute type="derived" value="Point (913209.0358 5606025.2373)" name="geometry"/>
12+
</Feature>
13+
<Feature id="1">
14+
<Attribute value="value PE" name="id"/>
15+
<Attribute value="two" name="name"/>
16+
<Attribute value="two àò" name="utf8nameè"/>
17+
<BoundingBox maxy="5606017.8743" maxx="913214.6741" miny="5606017.8743" CRS="EPSG:3857" minx="913214.6741"/>
18+
<Attribute type="derived" value="Point (913214.6741 5606017.8743)" name="geometry"/>
19+
</Feature>
20+
<Feature id="2">
21+
<Attribute value="value PE 1000 PN8" name="id"/>
22+
<Attribute value="three" name="name"/>
23+
<Attribute value="three èé↓" name="utf8nameè"/>
24+
<BoundingBox maxy="5606011.4565" maxx="913204.9128" miny="5606011.4565" CRS="EPSG:3857" minx="913204.9128"/>
25+
<Attribute type="derived" value="Point (913204.9128 5606011.4565)" name="geometry"/>
26+
</Feature>
27+
</Layer>
28+
</GetFeatureInfoResponse>
29+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<GetFeatureInfoResponse>
5+
<Layer name="layer3">
6+
<Feature id="1">
7+
<Attribute value="1" name="id"/>
8+
<Attribute value="Id no. 1 value, Id no. 2 value, Id número 3 value" name="location"/>
9+
<BoundingBox maxy="5606025.2373" maxx="913209.0358" miny="5606025.2373" CRS="EPSG:3857" minx="913209.0358"/>
10+
<Attribute type="derived" value="Point (913209.0358 5606025.2373)" name="geometry"/>
11+
</Feature>
12+
<Feature id="2">
13+
<Attribute value="2" name="id"/>
14+
<Attribute value="" name="location"/>
15+
<BoundingBox maxy="5606017.8743" maxx="913214.6741" miny="5606017.8743" CRS="EPSG:3857" minx="913214.6741"/>
16+
<Attribute type="derived" value="Point (913214.6741 5606017.8743)" name="geometry"/>
17+
</Feature>
18+
<Feature id="3">
19+
<Attribute value="3" name="id"/>
20+
<Attribute value="" name="location"/>
21+
<BoundingBox maxy="5606011.4565" maxx="913204.9128" miny="5606011.4565" CRS="EPSG:3857" minx="913204.9128"/>
22+
<Attribute type="derived" value="Point (913204.9128 5606011.4565)" name="geometry"/>
23+
</Feature>
24+
</Layer>
25+
</GetFeatureInfoResponse>

0 commit comments

Comments
 (0)
Please sign in to comment.