Skip to content
Permalink
Browse files
Update tests
  • Loading branch information
nyalldawson committed Aug 19, 2021
1 parent 6012caf commit 078accbdf23a557aa7cffe38b897ad5df2cf5221
Showing with 37 additions and 1 deletion.
  1. +37 −1 tests/src/python/test_provider_ogr.py
@@ -1649,7 +1649,7 @@ def test_provider_sublayer_details(self):
self.assertEqual(res[0].layerNumber(), 0)
self.assertEqual(res[0].name(), "multipatch")
self.assertEqual(res[0].description(), '')
self.assertEqual(res[0].uri(), TEST_DATA_DIR + "/multipatch.shp")
self.assertEqual(res[0].uri(), TEST_DATA_DIR + "/multipatch.shp|geometrytype=Polygon")
self.assertEqual(res[0].providerKey(), "ogr")
self.assertEqual(res[0].type(), QgsMapLayerType.VectorLayer)
self.assertEqual(res[0].wkbType(), QgsWkbTypes.Polygon)
@@ -1856,6 +1856,42 @@ def test_provider_sublayer_details(self):
self.assertTrue(vl.isValid())
self.assertEqual(vl.wkbType(), QgsWkbTypes.Polygon)

# a layer which reports unknown geometry type and requires a full table scan to resolve, but which only
# contains a single type of geometry
res = metadata.querySublayers(os.path.join(TEST_DATA_DIR, "mapinfo", "fill_styles.TAB"),
Qgis.SublayerQueryFlag.ResolveGeometryType)
self.assertEqual(len(res), 1)
self.assertEqual(res[0].layerNumber(), 0)
self.assertEqual(res[0].name(), "fill_styles")
self.assertEqual(res[0].description(), "")
self.assertEqual(res[0].uri(), "{}/mapinfo/fill_styles.TAB|geometrytype=Polygon".format(TEST_DATA_DIR))
self.assertEqual(res[0].providerKey(), "ogr")
self.assertEqual(res[0].type(), QgsMapLayerType.VectorLayer)
self.assertEqual(res[0].featureCount(), 49)
self.assertEqual(res[0].wkbType(), QgsWkbTypes.Polygon)
self.assertEqual(res[0].geometryColumnName(), '')
self.assertEqual(res[0].driverName(), 'MapInfo File')
vl = res[0].toLayer(options)
self.assertTrue(vl.isValid())
self.assertEqual(vl.wkbType(), QgsWkbTypes.Polygon)

# same, but don't resolve geometry types
res = metadata.querySublayers(os.path.join(TEST_DATA_DIR, "mapinfo", "fill_styles.TAB"))
self.assertEqual(len(res), 1)
self.assertEqual(res[0].layerNumber(), 0)
self.assertEqual(res[0].name(), "fill_styles")
self.assertEqual(res[0].description(), "")
self.assertEqual(res[0].uri(), "{}/mapinfo/fill_styles.TAB".format(TEST_DATA_DIR))
self.assertEqual(res[0].providerKey(), "ogr")
self.assertEqual(res[0].type(), QgsMapLayerType.VectorLayer)
self.assertEqual(res[0].featureCount(), Qgis.FeatureCountState.Uncounted)
self.assertEqual(res[0].wkbType(), QgsWkbTypes.Unknown)
self.assertEqual(res[0].geometryColumnName(), '')
self.assertEqual(res[0].driverName(), 'MapInfo File')
vl = res[0].toLayer(options)
self.assertTrue(vl.isValid())
self.assertEqual(vl.wkbType(), QgsWkbTypes.Polygon)

# mixed types source, but with a URI which specifies a particular type. Only this type should be returned
res = metadata.querySublayers(os.path.join(TEST_DATA_DIR, "mixed_types.TAB|geometrytype=Point"),
Qgis.SublayerQueryFlag.ResolveGeometryType)

0 comments on commit 078accb

Please sign in to comment.