Skip to content
Permalink
Browse files

extended the test for memory layers

The test now includes all geometry types including NoGeometry.
  • Loading branch information
SebDieBln committed Jan 8, 2016
1 parent 3977958 commit 6ef2f5ddb88d78134ec1e90f1ba94496a83a17df
Showing with 20 additions and 10 deletions.
  1. +20 −10 tests/src/python/test_provider_memory.py
@@ -69,20 +69,30 @@ def setUpClass(cls):
def tearDownClass(cls):
"""Run after all tests"""

def testPointCtor(self):
layer = QgsVectorLayer("Point", "test", "memory")
assert layer.isValid(), "Failed to create valid point memory layer"
def testCtors(self):
testVectors = ["Point", "LineString", "Polygon", "MultiPoint", "MultiLineString", "MultiPolygon", "None"]
for v in testVectors:
layer = QgsVectorLayer(v, "test", "memory")
assert layer.isValid(), "Failed to create valid %s memory layer" % (v)

def testLayerGeometry(self):
layer = QgsVectorLayer("Point", "test", "memory")
testVectors = [("Point", QGis.Point, QGis.WKBPoint),
("LineString", QGis.Line, QGis.WKBLineString),
("Polygon", QGis.Polygon, QGis.WKBPolygon),
("MultiPoint", QGis.Point, QGis.WKBMultiPoint),
("MultiLineString", QGis.Line, QGis.WKBMultiLineString),
("MultiPolygon", QGis.Polygon, QGis.WKBMultiPolygon),
("None", QGis.NoGeometry, QGis.WKBNoGeometry)]
for v in testVectors:
layer = QgsVectorLayer(v[0], "test", "memory")

myMessage = ('Expected: %s\nGot: %s\n' %
(QGis.Point, layer.geometryType()))
assert layer.geometryType() == QGis.Point, myMessage
myMessage = ('Expected: %s\nGot: %s\n' %
(v[1], layer.geometryType()))
assert layer.geometryType() == v[1], myMessage

myMessage = ('Expected: %s\nGot: %s\n' %
(QGis.WKBPoint, layer.wkbType()))
assert layer.wkbType() == QGis.WKBPoint, myMessage
myMessage = ('Expected: %s\nGot: %s\n' %
(v[2], layer.wkbType()))
assert layer.wkbType() == v[2], myMessage

def testAddFeatures(self):
layer = QgsVectorLayer("Point", "test", "memory")

0 comments on commit 6ef2f5d

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