Skip to content
Permalink
Browse files

Update tests, add new test for complex layer name

  • Loading branch information
nyalldawson committed Nov 26, 2017
1 parent 718e498 commit f04587eb670f2c5dbdee2f3b6ba316811daa7e42
Showing with 19 additions and 3 deletions.
  1. +19 −3 tests/src/python/test_provider_ogr_gpkg.py
@@ -33,7 +33,8 @@
QgsVectorLayerExporter,
QgsPointXY,
QgsProject,
QgsWkbTypes)
QgsWkbTypes,
QgsDataProvider)
from qgis.PyQt.QtCore import QCoreApplication, QVariant
from qgis.testing import start_app, unittest

@@ -113,7 +114,7 @@ def testCurveGeometryType(self):
ds = None

vl = QgsVectorLayer('{}'.format(tmpfile), 'test', 'ogr')
self.assertEqual(vl.dataProvider().subLayers(), ['0:test:0:CurvePolygon:geom'])
self.assertEqual(vl.dataProvider().subLayers(), [QgsDataProvider.SUBLAYER_SEPARATOR.join(['0', 'test', '0', 'CurvePolygon', 'geom'])])
f = QgsFeature()
f.setGeometry(QgsGeometry.fromWkt('POLYGON ((0 0,0 1,1 1,0 0))'))
vl.dataProvider().addFeatures([f])
@@ -601,6 +602,20 @@ def testReplaceLayerWhileOpen(self):
features = [f for f in vl1.getFeatures(request)]
self.assertEqual(len(features), 1)

def testSublayerWithComplexLayerName(self):
''' Test reading a gpkg with a sublayer name containing : '''
tmpfile = os.path.join(self.basetestpath, 'testGeopackageComplexLayerName.gpkg')
ds = ogr.GetDriverByName('GPKG').CreateDataSource(tmpfile)
lyr = ds.CreateLayer('layer1:', geom_type=ogr.wkbPoint, options=['GEOMETRY_NAME=geom:'])
lyr.CreateField(ogr.FieldDefn('attr', ogr.OFTInteger))
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometry(ogr.CreateGeometryFromWkt('POINT(0 0)'))
lyr.CreateFeature(f)
f = None

vl = QgsVectorLayer(u'{}'.format(tmpfile), u'layer', u'ogr')
self.assertEqual(vl.dataProvider().subLayers(), [QgsDataProvider.SUBLAYER_SEPARATOR.join(['0', 'layer1:', '1', 'Point', 'geom:'])])

def testGeopackageManyLayers(self):
''' test opening more than 64 layers without running out of Spatialite connections '''

@@ -669,7 +684,8 @@ def testGeopackageRefreshIfTableListUpdated(self):

vl2 = QgsVectorLayer(u'{}'.format(tmpfile), 'test', u'ogr')
vl2.subLayers()
self.assertEqual(vl2.dataProvider().subLayers(), ['0:test:0:Point:geom', '1:test2:0:Point:geom'])
self.assertEqual(vl2.dataProvider().subLayers(), [QgsDataProvider.SUBLAYER_SEPARATOR.join(['0', 'test', '0', 'Point', 'geom']),
QgsDataProvider.SUBLAYER_SEPARATOR.join(['1', 'test2', '0', 'Point', 'geom'])])

def testGeopackageLargeFID(self):

0 comments on commit f04587e

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