Skip to content

Commit

Permalink
Add test for lazy option
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Mar 2, 2018
1 parent 941aa0a commit 7b18fa8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/src/python/test_provider_virtual.py
Expand Up @@ -795,6 +795,26 @@ def test_layer_with_accents(self):

QgsProject.instance().removeMapLayer(l1.id())

def test_lazy(self):
l1 = QgsVectorLayer(os.path.join(self.testDataDir, "france_parts.shp"), "françéà", "ogr", QgsVectorLayer.LayerOptions(False))
self.assertEqual(l1.isValid(), True)
QgsProject.instance().addMapLayer(l1)

df = QgsVirtualLayerDefinition()
df.setQuery('select * from "françéà"')
df.setLazy(True)

vl = QgsVectorLayer(df.toString(), "testq", "virtual")
self.assertEqual(vl.isValid(), True)
ids = [f.id() for f in vl.getFeatures()]
self.assertEqual(len(ids), 0)

vl.reload()
ids = [f.id() for f in vl.getFeatures()]
self.assertEqual(len(ids), 4)

QgsProject.instance().removeMapLayer(l1.id())

def test_joined_layers_conversion(self):
v1 = QgsVectorLayer("Point?field=id:integer&field=b_id:integer&field=c_id:integer&field=name:string", "A", "memory")
self.assertEqual(v1.isValid(), True)
Expand Down

0 comments on commit 7b18fa8

Please sign in to comment.