Skip to content
Permalink
Browse files

Add test for lazy option

  • Loading branch information
pblottiere committed Mar 2, 2018
1 parent 941aa0a commit 7b18fa8becc60ad0515d2167981fd02e6c292df9
Showing with 20 additions and 0 deletions.
  1. +20 −0 tests/src/python/test_provider_virtual.py
@@ -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)

0 comments on commit 7b18fa8

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