Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Nov 16, 2017
1 parent 51d156d commit c6b054e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/src/python/test_provider_postgres.py
Expand Up @@ -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())

Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit c6b054e

Please sign in to comment.