Skip to content

Commit 8ee2e2c

Browse files
committed
Fix PyQgsServer test on GDAL >= 2.0
Also fix handling of longlong types in wfs_describefeaturetype (cherry-picked from 0780527)
1 parent 08a1b07 commit 8ee2e2c

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

src/server/qgswfsprojectparser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ void QgsWFSProjectParser::describeFeatureType( const QString& aTypeName, QDomEle
468468
QVariant::Type attributeType = fields[idx].type();
469469
if ( attributeType == QVariant::Int )
470470
attElem.setAttribute( "type", "integer" );
471+
else if ( attributeType == QVariant::LongLong )
472+
attElem.setAttribute( "type", "long" );
471473
else if ( attributeType == QVariant::Double )
472474
attElem.setAttribute( "type", "double" );
473475
else if ( attributeType == QVariant::Bool )

tests/src/python/test_qgsserver.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from qgis.core import QgsMessageLog
2222
from qgis.testing import unittest
2323
from utilities import unitTestDataPath
24+
import osgeo.gdal
2425

2526
# Strip path and content length because path may vary
2627
RE_STRIP_PATH = r'MAP=[^&]+|Content-Length: \d+'
@@ -163,6 +164,11 @@ def wms_request_compare(self, request, extra=None, reference_file=None):
163164
"""
164165
response = re.sub(RE_STRIP_PATH, '', response)
165166
expected = re.sub(RE_STRIP_PATH, '', expected)
167+
168+
# for older GDAL versions (<2.0), id field will be integer type
169+
if int(osgeo.gdal.VersionInfo()[:1]) < 2:
170+
expected = expected.replace('typeName="Integer64" precision="0" length="10" editType="TextEdit" type="qlonglong"', 'typeName="Integer" precision="0" length="10" editType="TextEdit" type="int"')
171+
166172
self.assertEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected, response))
167173

168174
def test_project_wms(self):
@@ -240,10 +246,15 @@ def wfs_request_compare(self, request):
240246
"""
241247
response = re.sub(RE_STRIP_PATH, '', response)
242248
expected = re.sub(RE_STRIP_PATH, '', expected)
249+
250+
# for older GDAL versions (<2.0), id field will be integer type
251+
if int(osgeo.gdal.VersionInfo()[:1]) < 2:
252+
expected = expected.replace('<element type="long" name="id"/>', '<element type="integer" name="id"/>')
253+
243254
self.assertEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected, response))
244255

245256
def test_project_wfs(self):
246-
"""Test some WMS request"""
257+
"""Test some WFS request"""
247258
for request in ('GetCapabilities', 'DescribeFeatureType'):
248259
self.wfs_request_compare(request)
249260

tests/testdata/qgis_server/getprojectsettings.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Content-Type: text/xml; charset=utf-8
150150
</Style>
151151
<TreeName>testlayer èé</TreeName>
152152
<Attributes>
153-
<Attribute typeName="Integer" precision="0" length="10" editType="TextEdit" type="int" comment="" name="id"/>
153+
<Attribute typeName="Integer64" precision="0" length="10" editType="TextEdit" type="qlonglong" comment="" name="id"/>
154154
<Attribute typeName="String" precision="0" length="10" editType="TextEdit" type="QString" comment="" name="name"/>
155155
<Attribute typeName="String" precision="0" length="13" editType="TextEdit" type="QString" comment="" name="utf8nameè"/>
156156
</Attributes>

tests/testdata/qgis_server/wfs_describefeaturetype.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Content-Type: text/xml; charset=utf-8
99
<extension base="gml:AbstractFeatureType">
1010
<sequence>
1111
<element minOccurs="0" maxOccurs="1" type="gml:GeometryPropertyType" name="geometry"/>
12-
<element type="integer" name="id"/>
12+
<element type="long" name="id"/>
1313
<element type="string" name="name"/>
1414
<element type="string" name="utf8nameè"/>
1515
</sequence>

0 commit comments

Comments
 (0)