"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/src/python/test_provider_ogr.py" between
QGIS-final-3_10_11.tar.gz and QGIS-final-3_10_12.tar.gz

About: QGIS (Quantum GIS) is a Geographic Information System that supports vector, raster, and database formats. Long-term release (3.10.x series).

test_provider_ogr.py  (QGIS-final-3_10_11):test_provider_ogr.py  (QGIS-final-3_10_12)
skipping to change at line 22 skipping to change at line 22
import os import os
import shutil import shutil
import sys import sys
import tempfile import tempfile
import hashlib import hashlib
from datetime import datetime from datetime import datetime
from osgeo import gdal, ogr # NOQA from osgeo import gdal, ogr # NOQA
from qgis.PyQt.QtCore import QVariant, QByteArray from qgis.PyQt.QtCore import QVariant, QByteArray
from qgis.core import (NULL, from qgis.core import (
QgsApplication, NULL,
QgsRectangle, QgsApplication,
QgsProviderRegistry, QgsProject,
QgsFeature, QgsFeatureRequest, QgsField, QgsSettings, Qgs QgsField,
DataProvider, QgsFields,
QgsVectorDataProvider, QgsVectorLayer, QgsWkbTypes, QgsNe QgsRectangle,
tworkAccessManager) QgsProviderRegistry,
QgsFeature,
QgsFeatureRequest,
QgsSettings,
QgsDataProvider,
QgsVectorDataProvider,
QgsVectorLayer,
QgsWkbTypes,
QgsNetworkAccessManager
)
from qgis.testing import start_app, unittest from qgis.testing import start_app, unittest
from utilities import unitTestDataPath from utilities import unitTestDataPath
from qgis.utils import spatialite_connect from qgis.utils import spatialite_connect
start_app() start_app()
TEST_DATA_DIR = unitTestDataPath() TEST_DATA_DIR = unitTestDataPath()
def GDAL_COMPUTE_VERSION(maj, min, rev): def GDAL_COMPUTE_VERSION(maj, min, rev):
return ((maj) * 1000000 + (min) * 10000 + (rev) * 100) return ((maj) * 1000000 + (min) * 10000 + (rev) * 100)
skipping to change at line 712 skipping to change at line 723
request = QgsFeatureRequest().setFilterExpression('"color" = 1') request = QgsFeatureRequest().setFilterExpression('"color" = 1')
self.assertCountEqual([f.attributes() for f in vl.getFeatures(request)], [['circle', '1'], self.assertCountEqual([f.attributes() for f in vl.getFeatures(request)], [['circle', '1'],
['rectangle', '1']]) ['rectangle', '1']])
vl.setSubsetString("\"shape\" = 'rectangle'") vl.setSubsetString("\"shape\" = 'rectangle'")
self.assertCountEqual([f.attributes() for f in vl.getFeatures()], [['rec tangle', '1'], self.assertCountEqual([f.attributes() for f in vl.getFeatures()], [['rec tangle', '1'],
['rec tangle', '2']]) ['rec tangle', '2']])
self.assertCountEqual([f.attributes() for f in vl.getFeatures(request)], [['rectangle', '1']]) self.assertCountEqual([f.attributes() for f in vl.getFeatures(request)], [['rectangle', '1']])
def testTransactionGroupExpressionFields(self):
"""Test issue GH #39230, this is not really specific to GPKG"""
project = QgsProject()
project.setAutoTransaction(True)
tmpfile = os.path.join(
self.basetestpath, 'tempGeoPackageTransactionExpressionFields.gpkg')
ds = ogr.GetDriverByName('GPKG').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('test', geom_type=ogr.wkbPoint)
lyr.CreateField(ogr.FieldDefn('str_field', ogr.OFTString))
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometry(ogr.CreateGeometryFromWkt('POINT (1 1)'))
f.SetField('str_field', 'one')
lyr.CreateFeature(f)
del lyr
del ds
vl = QgsVectorLayer(tmpfile + '|layername=test', 'test', 'ogr')
f = QgsField('expression_field', QVariant.Int)
idx = vl.addExpressionField('123', f)
self.assertEqual(vl.fields().fieldOrigin(idx), QgsFields.OriginExpressio
n)
project.addMapLayers([vl])
feature = next(vl.getFeatures())
feature.setAttributes([None, 'two', 123])
self.assertTrue(vl.startEditing())
self.assertTrue(vl.addFeature(feature))
self.assertFalse(vl.dataProvider().hasErrors())
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
 End of changes. 2 change blocks. 
8 lines changed or deleted 51 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)