Skip to content

Commit

Permalink
Add test for indexed memory provider thread safety
Browse files Browse the repository at this point in the history
Refs #17705
  • Loading branch information
nyalldawson committed Jan 16, 2018
1 parent 741afdc commit 38062ec
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/src/python/test_provider_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
QgsWkbTypes,
NULL,
QgsMemoryProviderUtils,
QgsCoordinateReferenceSystem
QgsCoordinateReferenceSystem,
QgsRectangle,
QgsTestUtils
)

from qgis.testing import (
Expand Down Expand Up @@ -413,6 +415,23 @@ def testCreateMemoryLayer(self):
self.assertEqual(layer.fields()[0].name(), 'rect')
self.assertEqual(layer.fields()[0].type(), QVariant.String) # should be mapped to string

def testThreadSafetyWithIndex(self):
layer = QgsVectorLayer('Point?crs=epsg:4326&index=yes&field=pk:integer&field=cnt:int8&field=name:string(0)&field=name2:string(0)&field=num_char:string&key=pk',
'test', 'memory')

provider = layer.dataProvider()
f = QgsFeature()
f.setAttributes([5, -200, NULL, 'NuLl', '5'])
f.setGeometry(QgsGeometry.fromWkt('Point (-71.123 78.23)'))

for i in range(100000):
provider.addFeatures([f])

# filter rect request
extent = QgsRectangle(-73, 70, -63, 80)
request = QgsFeatureRequest().setFilterRect(extent)
self.assertTrue(QgsTestUtils.testProviderIteratorThreadSafety(self.source, request))


class TestPyQgsMemoryProviderIndexed(unittest.TestCase, ProviderTestCase):

Expand Down

0 comments on commit 38062ec

Please sign in to comment.