diff --git a/.ci/test_blocklist_qt6.txt b/.ci/test_blocklist_qt6.txt
index f76522d3642..02501598276 100644
--- a/.ci/test_blocklist_qt6.txt
+++ b/.ci/test_blocklist_qt6.txt
@@ -86,7 +86,6 @@ PyQgsVectorLayerCache
PyQgsVectorLayerEditBuffer
PyQgsVectorLayerEditUtils
PyQgsLayerDefinition
-PyQgsWFSProvider
PyQgsSettings
PyQgsSettingsEntry
PyQgsSelectiveMasking
diff --git a/tests/src/python/test_provider_wfs.py b/tests/src/python/test_provider_wfs.py
index 1d4d5072c5a..bd72c415010 100644
--- a/tests/src/python/test_provider_wfs.py
+++ b/tests/src/python/test_provider_wfs.py
@@ -43,6 +43,7 @@ from qgis.core import (
QgsWkbTypes,
)
from qgis.PyQt.QtCore import (
+ QT_VERSION_STR,
QCoreApplication,
QDate,
QDateTime,
@@ -60,14 +61,16 @@ TEST_DATA_DIR = unitTestDataPath()
def sanitize(endpoint, x):
if len(endpoint + x) > 256:
- ret = endpoint + hashlib.md5(x.replace('/', '_').encode()).hexdigest()
# print('Before: ' + endpoint + x)
+ x = x.replace('/', '_').encode()
+ ret = endpoint + hashlib.md5(x).hexdigest()
# print('After: ' + ret)
return ret
ret = endpoint + x.replace('?', '_').replace('&', '_').replace('<', '_').replace('>', '_').replace('"',
'_').replace("'",
'_').replace(
' ', '_').replace(':', '_').replace('/', '_').replace('\n', '_')
+ # print('Sanitize: ' + x)
return ret
@@ -999,11 +1002,18 @@ class TestPyQgsWFSProvider(QgisTestCase, ProviderTestCase):
"""
- # Qt 5 order
+
+ if int(QT_VERSION_STR.split('.')[0]) >= 6:
+ attrs = 'xmlns="http://www.opengis.net/wfs" service="WFS" version="1.0.0" xmlns:gml="http://www.opengis.net/gml" xmlns:my="http://my" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my http://fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&VERSION=1.0.0&TYPENAME=my:typename"'
+ else:
+ attrs = '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&VERSION=1.0.0&TYPENAME=my:typename" xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml" version="1.0.0"'
+
with open(sanitize(transaction_endpoint,
- '?SERVICE=WFS&POSTDATA=11234567890123foo2016-04-10T12:34:56.789Z2,49'),
+ f'?SERVICE=WFS&POSTDATA=11234567890123foo2016-04-10T12:34:56.789Z2,49'),
'wb') as f:
f.write(response.encode('UTF-8'))
+
+ # Qt 4 order ??
with open(sanitize(transaction_endpoint,
'?SERVICE=WFS&POSTDATA=11234567890123foo2016-04-10T12:34:56.789Z2,49'),
'wb') as f:
@@ -1052,11 +1062,13 @@ class TestPyQgsWFSProvider(QgisTestCase, ProviderTestCase):
"""
- # Qt 5 order
+
with open(sanitize(transaction_endpoint,
- '?SERVICE=WFS&POSTDATA=my:geometryProperty3,50'),
+ f'?SERVICE=WFS&POSTDATA=my:geometryProperty3,50'),
'wb') as f:
f.write(content.encode('UTF-8'))
+
+ # Qt 4 order ??
with open(sanitize(transaction_endpoint,
'?SERVICE=WFS&POSTDATA=my:geometryProperty3,50'),
'wb') as f:
@@ -1091,11 +1103,12 @@ class TestPyQgsWFSProvider(QgisTestCase, ProviderTestCase):
"""
- # Qt 5 order
with open(sanitize(transaction_endpoint,
- '?SERVICE=WFS&POSTDATA=my:intfield2my:longfield3my:stringfieldbarmy:datetimefield2015-04-10T12:34:56.789Z'),
+ f'?SERVICE=WFS&POSTDATA=my:intfield2my:longfield3my:stringfieldbarmy:datetimefield2015-04-10T12:34:56.789Z'),
'wb') as f:
- f.write(content.encode('UTF-8'))
+ f.write(response.encode('UTF-8'))
+
+ # Qt 4 order ??
with open(sanitize(transaction_endpoint,
'?SERVICE=WFS&POSTDATA=my:intfield2my:longfield3my:stringfieldbarmy:datetimefield2015-04-10T12:34:56.789Z'),
'wb') as f:
@@ -1131,11 +1144,12 @@ class TestPyQgsWFSProvider(QgisTestCase, ProviderTestCase):
"""
- # Qt 5 order
with open(sanitize(transaction_endpoint,
- '?SERVICE=WFS&POSTDATA='),
+ f'?SERVICE=WFS&POSTDATA='),
'wb') as f:
- f.write(content.encode('UTF-8'))
+ f.write(response.encode('UTF-8'))
+
+ # Qt 4 order ??
with open(sanitize(transaction_endpoint,
'?SERVICE=WFS&POSTDATA='),
'wb') as f:
@@ -3573,8 +3587,13 @@ class TestPyQgsWFSProvider(QgisTestCase, ProviderTestCase):
extent = QgsRectangle(400000.0, 5400000.0, 450000.0, 5500000.0)
request = QgsFeatureRequest().setFilterRect(extent)
+ if int(QT_VERSION_STR.split('.')[0]) >= 6:
+ filter_attrs = 'xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:my="http://my"'
+ else:
+ filter_attrs = 'xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:my="http://my" xmlns:fes="http://www.opengis.net/fes/2.0"'
+
with open(sanitize(endpoint,
- """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::32631&FILTER=
+ f"""?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::32631&FILTER=
my:geometryProperty
@@ -3613,7 +3632,7 @@ class TestPyQgsWFSProvider(QgisTestCase, ProviderTestCase):
# is included in the filter
vl.setSubsetString('intfield = 2')
with open(sanitize(endpoint,
- """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::32631&FILTER=
+ f"""?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::32631&FILTER=
my:geometryProperty
@@ -3778,12 +3797,17 @@ class TestPyQgsWFSProvider(QgisTestCase, ProviderTestCase):
request.setExpressionContext(context)
request.setFilterExpression("intersects( $geometry, geometry(var('parent')))")
+ if int(QT_VERSION_STR.split('.')[0]) >= 6:
+ polygon_attrs = 'xmlns:gml="http://www.opengis.net/gml/3.2" srsName="urn:ogc:def:crs:EPSG::4326" gml:id="qgis_id_geom_1"'
+ else:
+ polygon_attrs = 'xmlns:gml="http://www.opengis.net/gml/3.2" gml:id="qgis_id_geom_1" srsName="urn:ogc:def:crs:EPSG::4326"'
+
with open(sanitize(endpoint,
- """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::4326&FILTER=
+ f"""?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::4326&FILTER=
geometryProperty
-
+
-20 -20 20 -20 20 20 -20 20 -20 -20
@@ -3834,12 +3858,17 @@ class TestPyQgsWFSProvider(QgisTestCase, ProviderTestCase):
request.setExpressionContext(context)
request.setFilterExpression("intersects( $geometry, geometry(var('parent')))")
+ if int(QT_VERSION_STR.split('.')[0]) >= 6:
+ filter_attrs = 'xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2"'
+ else:
+ filter_attrs = 'xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:fes="http://www.opengis.net/fes/2.0"'
+
with open(sanitize(endpoint,
- """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::4326&FILTER=
+ f"""?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::4326&FILTER=
geometryProperty
-
+
-20 -20 20 -20 20 20 -20 20 -20 -20
@@ -5314,7 +5343,13 @@ Can't recognize service requested.
# Test add features for real
# Transaction response with 1 feature added
- shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_added.xml'), sanitize(endpoint, '?SERVICE=WFS&POSTDATA=one<_name>1<_value>45 9 45 10 46 10 46 9 45 9<_gml:posList><_gml:LinearRing><_gml:exterior><_gml:Polygon><_geometry><_polygons><_Insert><_Transaction>'))
+
+ if int(QT_VERSION_STR.split('.')[0]) >= 6:
+ attrs = 'xmlns="http:__www.opengis.net_wfs" service="WFS" version="1.1.0" xmlns:gml="http:__www.opengis.net_gml" xmlns:ws1="ws1" xmlns:xsi="http:__www.w3.org_2001_XMLSchema-instance" xsi:schemaLocation="ws1 http:__fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&VERSION=1.0.0&TYPENAME=ws1:polygons"'
+ else:
+ attrs = 'xmlns="http:__www.opengis.net_wfs" xmlns:xsi="http:__www.w3.org_2001_XMLSchema-instance" xmlns:gml="http:__www.opengis.net_gml" xmlns:ws1="ws1" xsi:schemaLocation="ws1 http:__fake_qgis_http_endpoint?REQUEST=DescribeFeatureType&VERSION=1.0.0&TYPENAME=ws1:polygons" version="1.1.0" service="WFS"'
+
+ shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_added.xml'), sanitize(endpoint, f'?SERVICE=WFS&POSTDATA=one<_name>1<_value>45 9 45 10 46 10 46 9 45 9<_gml:posList><_gml:LinearRing><_gml:exterior><_gml:Polygon><_geometry><_polygons><_Insert><_Transaction>'))
feat = QgsFeature(vl.fields())
feat.setAttribute('name', 'one')
@@ -5326,14 +5361,14 @@ Can't recognize service requested.
# Test change attributes
# Transaction response with 1 feature changed
- shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_changed.xml'), sanitize(endpoint, '?SERVICE=WFS&POSTDATA=ws1:nameone-one-onews1:value111'))
+ shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_changed.xml'), sanitize(endpoint, f'?SERVICE=WFS&POSTDATA=ws1:nameone-one-onews1:value111'))
self.assertTrue(vl.dataProvider().changeAttributeValues({1: {0: 'one-one-one', 1: 111}}))
self.assertEqual(next(vl.dataProvider().getFeatures()).attributes(), ['one-one-one', 111])
# Test change geometry
# Transaction response with 1 feature changed
- shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_changed.xml'), sanitize(endpoint, '?SERVICE=WFS&POSTDATA=ws1:geometry<_Name>46 10 46 11 47 11 47 10 46 10<_gml:posList><_gml:LinearRing><_gml:exterior><_gml:Polygon><_Value><_Property><_Filter><_Update><_Transaction>'))
+ shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_changed.xml'), sanitize(endpoint, f'?SERVICE=WFS&POSTDATA=ws1:geometry<_Name>46 10 46 11 47 11 47 10 46 10<_gml:posList><_gml:LinearRing><_gml:exterior><_gml:Polygon><_Value><_Property><_Filter><_Update><_Transaction>'))
new_geom = QgsGeometry.fromWkt('Polygon ((10 46, 11 46, 11 47, 10 47, 10 46))')
@@ -5342,7 +5377,7 @@ Can't recognize service requested.
# Test delete feature
# Transaction response with 1 feature deleted
- shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_deleted.xml'), sanitize(endpoint, '?SERVICE=WFS&POSTDATA='))
+ shutil.copy(os.path.join(TEST_DATA_DIR, 'provider', 'wfst-1-1', 'transaction_response_feature_deleted.xml'), sanitize(endpoint, f'?SERVICE=WFS&POSTDATA='))
self.assertTrue(vl.dataProvider().deleteFeatures([1]))
self.assertEqual(vl.featureCount(), 0)