Skip to content
Permalink
Browse files

Add test for indexed memory provider thread safety

Refs #17705
  • Loading branch information
nyalldawson committed Jan 15, 2018
1 parent 741afdc commit 38062ec6494a66a2b6947f1cda75d58cebc5a567
Showing with 20 additions and 1 deletion.
  1. +20 −1 tests/src/python/test_provider_memory.py
@@ -26,7 +26,9 @@
QgsWkbTypes,
NULL,
QgsMemoryProviderUtils,
QgsCoordinateReferenceSystem
QgsCoordinateReferenceSystem,
QgsRectangle,
QgsTestUtils
)

from qgis.testing import (
@@ -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):

0 comments on commit 38062ec

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