Skip to content
Permalink
Browse files

added test to avoid convertion from multy to single

  • Loading branch information
luipir committed Sep 26, 2017
1 parent 99cf08f commit a7e704ef5e4a208f8430c4dd5af2e48c9092c563
Showing with 12 additions and 8 deletions.
  1. +12 −8 tests/src/python/test_qgsvectorlayereditbuffer.py
@@ -118,7 +118,7 @@ def testAddFeatures(self):
self.assertFalse((layer.editBuffer().addFeatures([f1])))

# check is possibile to adapt single to multi
# This test should belog to vectordataprovider test
# This test should belong to vectordataprovider test
layer = createEmptyMultiLinestringLayer()
self.assertTrue(layer.startEditing())
self.assertEqual(layer.editBuffer().addedFeatures(), {})
@@ -133,18 +133,22 @@ def testAddFeatures(self):
self.assertTrue(QgsWKBTypes.isSingleType(QGis.fromOldWkbType(geom.wkbType())))
self.assertTrue((layer.editBuffer().addFeatures([f1])))

# check is possibile to adapt 3D geom to 2D provider type
# This test should belog to vectordataprovider test
layer = createEmptyLayer()
# check that is NOT possibile to adapt Multi to single if only one simple geometry
# This because to avoid to have a bunch of successful import for that
# thac can be converted and other feature that fails => better leave to
# the user the explicit work to convert to singletype
layer = createEmptyLinestringLayer()
self.assertTrue(layer.startEditing())
self.assertEqual(layer.editBuffer().addedFeatures(), {})
geom = QgsGeometry.fromPoint(QgsPoint(1, 1))
geom.geometry().addZValue(1)
self.assertTrue(QgsWKBTypes.hasZ(geom.geometry().wkbType()))
multiline = [
[QgsPoint(1, 1), QgsPoint(2, 2), QgsPoint(3, 3)]
]
geom = QgsGeometry.fromMultiPolyline(multiline)
self.assertTrue(QgsWKBTypes.isMultiType(QGis.fromOldWkbType(geom.wkbType())))
f1 = QgsFeature(layer.fields(), 1)
f1.setGeometry(geom)
f1.setAttributes(["test", 123])
self.assertTrue((layer.editBuffer().addFeatures([f1])))
self.assertFalse((layer.editBuffer().addFeatures([f1])))

def testAddMultipleFeatures(self):
# test adding multiple features to an edit buffer

0 comments on commit a7e704e

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