Skip to content

Commit

Permalink
extended the test for memory layers
Browse files Browse the repository at this point in the history
The test now includes all geometry types including NoGeometry.
  • Loading branch information
SebDieBln committed Jan 8, 2016
1 parent 3977958 commit 6ef2f5d
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions tests/src/python/test_provider_memory.py
Expand Up @@ -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")
Expand Down

0 comments on commit 6ef2f5d

Please sign in to comment.