Skip to content

Commit 9a49c6a

Browse files
committedMay 15, 2016
Make ogcutils and WFS tests Qt 5 compatible
1 parent bf91a8b commit 9a49c6a

File tree

4 files changed

+65
-43
lines changed

4 files changed

+65
-43
lines changed
 

‎ci/travis/linux/qt5/blacklist.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ PyQgsSipCoverage
1818
PyQgsSpatialiteProvider
1919
PyQgsVirtualLayerDefinition
2020
PyQgsVirtualLayerProvider
21-
PyQgsWFSProvider
22-
PyQgsWFSProviderGUI
2321
qgis_composermapgridtest
2422
qgis_composertabletest
2523
qgis_composertablev2test

‎tests/src/core/testqgsogcutils.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class TestQgsOgcUtils : public QObject
3232

3333
void initTestCase()
3434
{
35+
// Needed on Qt 5 so that the serialization of XML is consistant among all executions
36+
qputenv( "QT_HASH_SEED", "1" );
37+
3538
//
3639
// Runs once before any tests are run
3740
//
@@ -57,10 +60,8 @@ class TestQgsOgcUtils : public QObject
5760
void testExpressionToOgcFilterWFS11();
5861
void testExpressionToOgcFilterWFS11_data();
5962

60-
#if QT_VERSION < 0x050000
6163
void testExpressionToOgcFilterWFS20();
6264
void testExpressionToOgcFilterWFS20_data();
63-
#endif
6465

6566
void testSQLStatementToOgcFilter();
6667
void testSQLStatementToOgcFilter_data();
@@ -428,8 +429,12 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS11_data()
428429
"</ogc:Filter>" );
429430
}
430431

431-
// There's an issue with QT 5 that appears to reverse the order of multiple attributes
432-
#if QT_VERSION < 0x050000
432+
static QString normalizeXML( const QString& xmlText )
433+
{
434+
QDomDocument doc;
435+
doc.setContent( xmlText, true );
436+
return doc.toString( -1 );
437+
}
433438

434439
void TestQgsOgcUtils::testExpressionToOgcFilterWFS20()
435440
{
@@ -456,7 +461,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS20()
456461
qDebug( "SRSNAME: %s", srsName.toAscii().data() );
457462
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );
458463

459-
QCOMPARE( xmlText, doc.toString( -1 ) );
464+
QCOMPARE( normalizeXML( xmlText ), normalizeXML( doc.toString( -1 ) ) );
460465
}
461466

462467
void TestQgsOgcUtils::testExpressionToOgcFilterWFS20_data()
@@ -504,8 +509,6 @@ void TestQgsOgcUtils::testExpressionToOgcFilterWFS20_data()
504509
"</fes:Filter>" );
505510
}
506511

507-
#endif
508-
509512
Q_DECLARE_METATYPE( QgsOgcUtils::GMLVersion )
510513
Q_DECLARE_METATYPE( QgsOgcUtils::FilterVersion )
511514
Q_DECLARE_METATYPE( QList<QgsOgcUtils::LayerProperties> )
@@ -558,7 +561,7 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter()
558561
filterVersion == QgsOgcUtils::FILTER_FES_2_0 ? "FES 2.0" : "unknown" );
559562
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );
560563

561-
QCOMPARE( doc.toString( -1 ), xmlText );
564+
QCOMPARE( normalizeXML( xmlText ), normalizeXML( doc.toString( -1 ) ) );
562565
}
563566

564567
void TestQgsOgcUtils::testSQLStatementToOgcFilter_data()
@@ -742,9 +745,6 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter_data()
742745
"</ogc:BBOX>"
743746
"</ogc:Filter>" );
744747

745-
// There's an issue with QT 5 that appears to reverse the order of multiple attributes
746-
#if QT_VERSION < 0x050000
747-
748748
QTest::newRow( "intersects + wkt + explicit srs" ) << QString( "SELECT * FROM t WHERE ST_Intersects(geom, ST_GeometryFromText('POINT (5 6)', 'urn:ogc:def:crs:EPSG::4326'))" ) <<
749749
QgsOgcUtils::GML_3_2_1 << QgsOgcUtils::FILTER_FES_2_0 << layerProperties << QString(
750750
"<fes:Filter xmlns:fes=\"http://www.opengis.net/fes/2.0\" xmlns:gml=\"http://www.opengis.net/gml/3.2\">"
@@ -852,9 +852,7 @@ void TestQgsOgcUtils::testSQLStatementToOgcFilter_data()
852852
"</fes:PropertyIsEqualTo>"
853853
"</fes:And>"
854854
"</fes:Filter>" );
855-
#endif
856855
}
857856

858-
859857
QTEST_MAIN( TestQgsOgcUtils )
860858
#include "testqgsogcutils.moc"

‎tests/src/python/test_provider_wfs.py

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import tempfile
1818
import shutil
1919

20+
# Needed on Qt 5 so that the serialization of XML is consistant among all executions
21+
os.environ['QT_HASH_SEED'] = '1'
22+
2023
from qgis.PyQt.QtCore import Qt, QObject, QDateTime
2124

2225
from qgis.core import (
@@ -397,7 +400,7 @@ def testWFS10(self):
397400
reference = QgsGeometry.fromRect(
398401
QgsRectangle(-71.123, 66.33, -65.32, 78.3))
399402
vl_extent = QgsGeometry.fromRect(vl.extent())
400-
assert QgsGeometry.compare(vl_extent.asPolygon(), reference.asPolygon(), 0.00001), 'Expected {}, got {}'.format(reference.exportToWkt(), vl_extent.exportToWkt())
403+
assert QgsGeometry.compare(vl_extent.asPolygon()[0], reference.asPolygon()[0], 0.00001), 'Expected {}, got {}'.format(reference.exportToWkt(), vl_extent.exportToWkt())
401404

402405
with open(sanitize(endpoint, '?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&TYPENAME=my:typename&SRSNAME=EPSG:4326'), 'wb') as f:
403406
f.write("""
@@ -439,7 +442,8 @@ def testWFS10(self):
439442
values = [f['datetimefield'] for f in vl.getFeatures()]
440443
self.assertEqual(values, [QDateTime(2016, 4, 10, 12, 34, 56, 789, Qt.TimeSpec(Qt.UTC))])
441444

442-
got = [f.geometry() for f in vl.getFeatures()][0].geometry()
445+
got_f = [f for f in vl.getFeatures()]
446+
got = got_f[0].geometry().geometry()
443447
self.assertEqual((got.x(), got.y()), (2.0, 49.0))
444448

445449
self.assertEqual(vl.featureCount(), 1)
@@ -521,8 +525,7 @@ def testWFST10(self):
521525
assert not vl.dataProvider().changeAttributeValues({0: {0: 0}})
522526

523527
# Test addFeatures
524-
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml"><Insert xmlns="http://www.opengis.net/wfs"><typename xmlns="http://my"><intfield xmlns="http://my">1</intfield><longfield xmlns="http://my">1234567890123</longfield><stringfield xmlns="http://my">foo</stringfield><datetimefield xmlns="http://my">2016-04-10T12:34:56.789Z</datetimefield><geometryProperty xmlns="http://my"><gml:Point srsName="EPSG:4326"><gml:coordinates cs="," ts=" ">2,49</gml:coordinates></gml:Point></geometryProperty></typename></Insert></Transaction>'), 'wb') as f:
525-
f.write("""
528+
response = """
526529
<wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc">
527530
<wfs:InsertResult>
528531
<ogc:FeatureId fid="typename.1" />
@@ -533,7 +536,14 @@ def testWFST10(self):
533536
</wfs:Status>
534537
</wfs:TransactionResult>
535538
</wfs:WFS_TransactionResponse>
536-
""".encode('UTF-8'))
539+
"""
540+
# Qt 4 order
541+
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml"><Insert xmlns="http://www.opengis.net/wfs"><typename xmlns="http://my"><intfield xmlns="http://my">1</intfield><longfield xmlns="http://my">1234567890123</longfield><stringfield xmlns="http://my">foo</stringfield><datetimefield xmlns="http://my">2016-04-10T12:34:56.789Z</datetimefield><geometryProperty xmlns="http://my"><gml:Point srsName="EPSG:4326"><gml:coordinates cs="," ts=" ">2,49</gml:coordinates></gml:Point></geometryProperty></typename></Insert></Transaction>'), 'wb') as f:
542+
f.write(response.encode('UTF-8'))
543+
544+
# Qt 5 order
545+
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml" version="1.0.0"><Insert xmlns="http://www.opengis.net/wfs"><typename xmlns="http://my"><intfield xmlns="http://my">1</intfield><longfield xmlns="http://my">1234567890123</longfield><stringfield xmlns="http://my">foo</stringfield><datetimefield xmlns="http://my">2016-04-10T12:34:56.789Z</datetimefield><geometryProperty xmlns="http://my"><gml:Point srsName="EPSG:4326"><gml:coordinates cs="," ts=" ">2,49</gml:coordinates></gml:Point></geometryProperty></typename></Insert></Transaction>'), 'wb') as f:
546+
f.write(response.encode('UTF-8'))
537547

538548
f = QgsFeature()
539549
f.setAttributes([1, 1234567890123, 'foo', QDateTime(2016, 4, 10, 12, 34, 56, 789, Qt.TimeSpec(Qt.UTC))])
@@ -556,25 +566,33 @@ def testWFST10(self):
556566
values = [f['datetimefield'] for f in vl.getFeatures()]
557567
self.assertEqual(values, [QDateTime(2016, 4, 10, 12, 34, 56, 789, Qt.TimeSpec(Qt.UTC))])
558568

559-
got = [f.geometry() for f in vl.getFeatures()][0].geometry()
569+
got_f = [f for f in vl.getFeatures()]
570+
got = got_f[0].geometry().geometry()
560571
self.assertEqual((got.x(), got.y()), (2.0, 49.0))
561572

562573
# Test changeGeometryValues
563-
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml"><Update xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">geometryProperty</Name><Value xmlns="http://www.opengis.net/wfs"><gml:Point srsName="EPSG:4326"><gml:coordinates cs="," ts=" ">3,50</gml:coordinates></gml:Point></Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Update></Transaction>'), 'wb') as f:
564-
f.write("""
574+
content = """
565575
<wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc">
566576
<wfs:TransactionResult>
567577
<wfs:Status>
568578
<wfs:SUCCESS/>
569579
</wfs:Status>
570580
</wfs:TransactionResult>
571581
</wfs:WFS_TransactionResponse>
572-
""".encode('UTF-8'))
582+
"""
583+
# Qt 4 order
584+
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml"><Update xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">geometryProperty</Name><Value xmlns="http://www.opengis.net/wfs"><gml:Point srsName="EPSG:4326"><gml:coordinates cs="," ts=" ">3,50</gml:coordinates></gml:Point></Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Update></Transaction>'), 'wb') as f:
585+
f.write(content.encode('UTF-8'))
586+
587+
# Qt 5 order
588+
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml" version="1.0.0"><Update xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">geometryProperty</Name><Value xmlns="http://www.opengis.net/wfs"><gml:Point srsName="EPSG:4326"><gml:coordinates cs="," ts=" ">3,50</gml:coordinates></gml:Point></Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Update></Transaction>'), 'wb') as f:
589+
f.write(content.encode('UTF-8'))
573590

574591
ret = vl.dataProvider().changeGeometryValues({1: QgsGeometry.fromWkt('Point (3 50)')})
575592
assert ret
576593

577-
got = [f.geometry() for f in vl.getFeatures()][0].geometry()
594+
got_f = [f for f in vl.getFeatures()]
595+
got = got_f[0].geometry().geometry()
578596
self.assertEqual((got.x(), got.y()), (3.0, 50.0))
579597

580598
values = [f['intfield'] for f in vl.getFeatures()]
@@ -590,16 +608,22 @@ def testWFST10(self):
590608
self.assertEqual(values, [QDateTime(2016, 4, 10, 12, 34, 56, 789, Qt.TimeSpec(Qt.UTC))])
591609

592610
# Test changeAttributeValues
593-
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml"><Update xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">intfield</Name><Value xmlns="http://www.opengis.net/wfs">2</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">longfield</Name><Value xmlns="http://www.opengis.net/wfs">3</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">stringfield</Name><Value xmlns="http://www.opengis.net/wfs">bar</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">datetimefield</Name><Value xmlns="http://www.opengis.net/wfs">2015-04-10T12:34:56.789Z</Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Update></Transaction>'), 'wb') as f:
594-
f.write("""
611+
content = """
595612
<wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc">
596613
<wfs:TransactionResult>
597614
<wfs:Status>
598615
<wfs:SUCCESS/>
599616
</wfs:Status>
600617
</wfs:TransactionResult>
601618
</wfs:WFS_TransactionResponse>
602-
""".encode('UTF-8'))
619+
"""
620+
# Qt 4 order
621+
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml"><Update xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">intfield</Name><Value xmlns="http://www.opengis.net/wfs">2</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">longfield</Name><Value xmlns="http://www.opengis.net/wfs">3</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">stringfield</Name><Value xmlns="http://www.opengis.net/wfs">bar</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">datetimefield</Name><Value xmlns="http://www.opengis.net/wfs">2015-04-10T12:34:56.789Z</Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Update></Transaction>'), 'wb') as f:
622+
f.write(content.encode('UTF-8'))
623+
# Qt 5 order
624+
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml" version="1.0.0"><Update xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">intfield</Name><Value xmlns="http://www.opengis.net/wfs">2</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">longfield</Name><Value xmlns="http://www.opengis.net/wfs">3</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">stringfield</Name><Value xmlns="http://www.opengis.net/wfs">bar</Value></Property><Property xmlns="http://www.opengis.net/wfs"><Name xmlns="http://www.opengis.net/wfs">datetimefield</Name><Value xmlns="http://www.opengis.net/wfs">2015-04-10T12:34:56.789Z</Value></Property><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Update></Transaction>'), 'wb') as f:
625+
f.write(content.encode('UTF-8'))
626+
603627
assert vl.dataProvider().changeAttributeValues({1: {0: 2, 1: 3, 2: "bar", 3: QDateTime(2015, 4, 10, 12, 34, 56, 789, Qt.TimeSpec(Qt.UTC))}})
604628

605629
values = [f['intfield'] for f in vl.getFeatures()]
@@ -614,20 +638,27 @@ def testWFST10(self):
614638
values = [f['datetimefield'] for f in vl.getFeatures()]
615639
self.assertEqual(values, [QDateTime(2015, 4, 10, 12, 34, 56, 789, Qt.TimeSpec(Qt.UTC))])
616640

617-
got = [f.geometry() for f in vl.getFeatures()][0].geometry()
641+
got_f = [f for f in vl.getFeatures()]
642+
got = got_f[0].geometry().geometry()
618643
self.assertEqual((got.x(), got.y()), (3.0, 50.0))
619644

620645
# Test deleteFeatures
621-
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml"><Delete xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Delete></Transaction>'), 'wb') as f:
622-
f.write("""
646+
content = """
623647
<wfs:WFS_TransactionResponse version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc">
624648
<wfs:TransactionResult>
625649
<wfs:Status>
626650
<wfs:SUCCESS/>
627651
</wfs:Status>
628652
</wfs:TransactionResult>
629653
</wfs:WFS_TransactionResponse>
630-
""".encode('UTF-8'))
654+
"""
655+
# Qt 4 order
656+
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" service="WFS" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml"><Delete xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Delete></Transaction>'), 'wb') as f:
657+
f.write(content.encode('UTF-8'))
658+
# Qt 5 order
659+
with open(sanitize(endpoint, '?SERVICE=WFS&POSTDATA=<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&amp;VERSION=1.0.0&amp;TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml" version="1.0.0"><Delete xmlns="http://www.opengis.net/wfs" typeName="my:typename"><Filter xmlns="http://www.opengis.net/ogc"><FeatureId xmlns="http://www.opengis.net/ogc" fid="typename.1"/></Filter></Delete></Transaction>'), 'wb') as f:
660+
f.write(content.encode('UTF-8'))
661+
631662
assert vl.dataProvider().deleteFeatures([1])
632663

633664
self.assertEqual(vl.featureCount(), 0)
@@ -1310,7 +1341,7 @@ def testJoins(self):
13101341
# main table not appearing in first
13111342

13121343
with open(sanitize(endpoint, '?SERVICE=WFS&REQUEST=DescribeFeatureType&VERSION=2.0.0&TYPENAME=my:othertypename,my:typename'), 'wb') as f:
1313-
f.write(schema)
1344+
f.write(schema.encode('UTF-8'))
13141345

13151346
vl = QgsVectorLayer(u"url='http://" + endpoint + u"' typename='my:typename' version='2.0.0' sql=SELECT * FROM othertypename o, typename WHERE typename.id = o.main_id AND typename.id > 0 ORDER BY typename.id DESC", u'test', u'WFS')
13161347
assert vl.isValid()

‎tests/src/python/test_provider_wfs_gui.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,14 @@ def test(self):
213213
self.assertIsNotNone(btnConnect)
214214
QTest.mouseClick(btnConnect, Qt.LeftButton)
215215

216-
# We need to show (and raise for Mac) the dialog so that the focus changes
217-
self.loop = QEventLoop()
218-
treeView = main_dialog.findChild(QTreeView, "treeView")
219-
treeView.selectionModel().currentRowChanged.connect(main_dialog.hide)
220-
treeView.selectionModel().currentRowChanged.connect(self.loop.quit)
221-
main_dialog.show()
222-
main_dialog.raise_()
223-
self.loop.exec_()
224-
225-
# Add layer
226216
buttonAdd = self.get_button_add(main_dialog)
217+
for i in range(10):
218+
QApplication.processEvents()
219+
if buttonAdd.isEnabled():
220+
break
227221
self.assertTrue(buttonAdd.isEnabled())
228222

223+
# Add layer
229224
self.addWfsLayer_uri = None
230225
self.addWfsLayer_layer_name = None
231226
main_dialog.addWfsLayer.connect(self.slotAddWfsLayer)

0 commit comments

Comments
 (0)
Please sign in to comment.