Skip to content
Permalink
Browse files

Test updates for changed method name/signature

  • Loading branch information
m-kuhn committed Sep 29, 2017
1 parent 17fe7e8 commit 1552b4ed3b07de323dbf887772f838893695202e
@@ -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
@@ -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])

@@ -27,7 +27,8 @@
QgsProject,
QgsFieldConstraints,
QgsVectorLayerUtils,
QgsSettings)
QgsSettings,
QgsDefaultValue)

from qgis.testing import start_app, unittest
from utilities import unitTestDataPath
@@ -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])

@@ -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)

0 comments on commit 1552b4e

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