Skip to content
Permalink
Browse files

Add test

  • Loading branch information
pblottiere committed Nov 16, 2017
1 parent 51d156d commit c6b054ed4d3ee553be549812565deae60bbc3b59
Showing with 20 additions and 3 deletions.
  1. +20 −3 tests/src/python/test_provider_postgres.py
@@ -351,8 +351,8 @@ def testTimeout(self):
for i in range(100):
iterators.append(self.vl.getFeatures(request))

def testTransactionNotDirty(self):
# create a vector ayer based on postgres
def testTransactionDirty(self):
# create a vector layer based on postgres
vl = QgsVectorLayer(self.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="qgis_test"."some_poly_data" (geom) sql=', 'test', 'postgres')
self.assertTrue(vl.isValid())

@@ -397,7 +397,24 @@ def testTransactionNotDirty(self):
ft1 = vl.getFeatures('pk=1')
self.assertFalse(ft1.nextFeature(f))

p.setAutoTransaction(False)
def testTransactionTuple(self):
# create a vector layer based on postgres
vl = QgsVectorLayer(self.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="qgis_test"."some_poly_data" (geom) sql=', 'test', 'postgres')
self.assertTrue(vl.isValid())

# prepare a project with transactions enabled
p = QgsProject()
p.setAutoTransaction(True)
p.addMapLayers([vl])
vl.startEditing()

# execute a query which returns a tuple
tr = vl.dataProvider().transaction()
sql = "select * from qgis_test.some_poly_data"
self.assertTrue(tr.executeSql(sql, False)[0])

# underlying data has not been modified
self.assertFalse(vl.isModified())

def testDomainTypes(self):
"""Test that domain types are correctly mapped"""

0 comments on commit c6b054e

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