Skip to content
Permalink
Browse files

Merge pull request #2862 from nyalldawson/server_test_gdal

Fix PyQgsServer test on GDAL >= 2.0 and fix handling of longlong types
  • Loading branch information
nyalldawson committed Mar 17, 2016
2 parents cc650f9 + 0780527 commit 81d4d086d68011fac566cd39f8bd947182737427
@@ -468,6 +468,8 @@ void QgsWFSProjectParser::describeFeatureType( const QString& aTypeName, QDomEle
QVariant::Type attributeType = fields[idx].type();
if ( attributeType == QVariant::Int )
attElem.setAttribute( "type", "integer" );
else if ( attributeType == QVariant::LongLong )
attElem.setAttribute( "type", "long" );
else if ( attributeType == QVariant::Double )
attElem.setAttribute( "type", "double" );
else if ( attributeType == QVariant::Bool )
@@ -21,6 +21,7 @@
from qgis.core import QgsMessageLog
from qgis.testing import unittest
from utilities import unitTestDataPath
import osgeo.gdal

# Strip path and content length because path may vary
RE_STRIP_PATH = r'MAP=[^&]+|Content-Length: \d+'
@@ -163,6 +164,11 @@ def wms_request_compare(self, request, extra=None, reference_file=None):
"""
response = re.sub(RE_STRIP_PATH, '', response)
expected = re.sub(RE_STRIP_PATH, '', expected)

# for older GDAL versions (<2.0), id field will be integer type
if int(osgeo.gdal.VersionInfo()[:1]) < 2:
expected = expected.replace('typeName="Integer64" precision="0" length="10" editType="TextEdit" type="qlonglong"', 'typeName="Integer" precision="0" length="10" editType="TextEdit" type="int"')

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))

def test_project_wms(self):
@@ -240,10 +246,15 @@ def wfs_request_compare(self, request):
"""
response = re.sub(RE_STRIP_PATH, '', response)
expected = re.sub(RE_STRIP_PATH, '', expected)

# for older GDAL versions (<2.0), id field will be integer type
if int(osgeo.gdal.VersionInfo()[:1]) < 2:
expected = expected.replace('<element type="long" name="id"/>', '<element type="integer" name="id"/>')

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))

def test_project_wfs(self):
"""Test some WMS request"""
"""Test some WFS request"""
for request in ('GetCapabilities', 'DescribeFeatureType'):
self.wfs_request_compare(request)

@@ -150,7 +150,7 @@ Content-Type: text/xml; charset=utf-8
</Style>
<TreeName>testlayer èé</TreeName>
<Attributes>
<Attribute typeName="Integer" precision="0" length="10" editType="TextEdit" type="int" comment="" name="id"/>
<Attribute typeName="Integer64" precision="0" length="10" editType="TextEdit" type="qlonglong" comment="" name="id"/>
<Attribute typeName="String" precision="0" length="10" editType="TextEdit" type="QString" comment="" name="name"/>
<Attribute typeName="String" precision="0" length="13" editType="TextEdit" type="QString" comment="" name="utf8nameè"/>
</Attributes>
@@ -9,7 +9,7 @@ Content-Type: text/xml; charset=utf-8
<extension base="gml:AbstractFeatureType">
<sequence>
<element minOccurs="0" maxOccurs="1" type="gml:GeometryPropertyType" name="geometry"/>
<element type="integer" name="id"/>
<element type="long" name="id"/>
<element type="string" name="name"/>
<element type="string" name="utf8nameè"/>
</sequence>

0 comments on commit 81d4d08

Please sign in to comment.
You can’t perform that action at this time.