Skip to content

Commit

Permalink
Test updates for changed method name/signature
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 29, 2017
1 parent 17fe7e8 commit 1552b4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions tests/src/python/test_provider_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
QgsSettings,
QgsTransactionGroup,
QgsReadWriteContext,
QgsRectangle
QgsRectangle,
QgsDefaultValue
)
from qgis.gui import QgsGui
from qgis.PyQt.QtCore import QDate, QTime, QDateTime, QVariant, QDir, QObject
Expand Down Expand Up @@ -589,7 +590,7 @@ def testVectorLayerUtilsCreateFeatureWithProviderDefault(self):
self.assertEqual(f.attributes(), [default_clause, 5, "'qgis'::text", "'qgis'::text", None, None])

# test take vector layer default value expression overrides postgres provider default clause
vl.setDefaultValueExpression(3, "'mappy'")
vl.setDefaultValueDefinition(3, QgsDefaultValue("'mappy'"))
f = QgsVectorLayerUtils.createFeature(vl, attributes={1: 5, 3: 'map'})
self.assertEqual(f.attributes(), [default_clause, 5, "'qgis'::text", 'mappy', None, None])

Expand Down
5 changes: 3 additions & 2 deletions tests/src/python/test_provider_spatialite.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
QgsProject,
QgsFieldConstraints,
QgsVectorLayerUtils,
QgsSettings)
QgsSettings,
QgsDefaultValue)

from qgis.testing import start_app, unittest
from utilities import unitTestDataPath
Expand Down Expand Up @@ -553,7 +554,7 @@ def testVectorLayerUtilsCreateFeatureWithProviderDefaultLiteral(self):
self.assertEqual(f.attributes(), [3, "qgis 'is good", 5, 5.7, None])

# test that vector layer default value expression overrides provider default literal
vl.setDefaultValueExpression(3, "4*3")
vl.setDefaultValueDefinition(3, QgsDefaultValue("4*3"))
f = QgsVectorLayerUtils.createFeature(vl, attributes={1: 'qgis is great', 0: 3})
self.assertEqual(f.attributes(), [3, "qgis 'is good", 5, 12, None])

Expand Down
6 changes: 3 additions & 3 deletions tests/src/python/test_qgsvectorlayerutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,17 @@ def testCreateFeature(self):
self.assertEqual(f.attributes(), ['a', NULL, 6.0])

# layer with default value expression
layer.setDefaultValueExpression(2, '3*4')
layer.setDefaultValueDefinition(2, QgsDefaultValue('3*4'))
f = QgsVectorLayerUtils.createFeature(layer)
self.assertEqual(f.attributes(), [NULL, NULL, 12.0])
# we expect the default value expression to take precedence over the attribute map
f = QgsVectorLayerUtils.createFeature(layer, attributes={0: 'a', 2: 6.0})
self.assertEqual(f.attributes(), ['a', NULL, 12.0])
# layer with default value expression based on geometry
layer.setDefaultValueExpression(2, '3*$x')
layer.setDefaultValueDefinition(2, QgsDefaultValue('3*$x'))
f = QgsVectorLayerUtils.createFeature(layer, g)
self.assertEqual(f.attributes(), [NULL, NULL, 300.0])
layer.setDefaultValueExpression(2, None)
layer.setDefaultValueDefinition(2, QgsDefaultValue(None))

# test with violated unique constraints
layer.setFieldConstraint(1, QgsFieldConstraints.ConstraintUnique)
Expand Down

0 comments on commit 1552b4e

Please sign in to comment.