Skip to content
Permalink
Browse files

[bugfix] Add failing test for OGR setSubsetString

Fails to revert to rw after a subset string is set and cleared
  • Loading branch information
elpaso committed Jan 5, 2018
1 parent 227dc9c commit dd60fcd4fc23371f39bbb83b9b82473e80b158d7
Showing with 19 additions and 0 deletions.
  1. +19 −0 tests/src/python/test_provider_ogr.py
@@ -318,6 +318,25 @@ def testSetupProxy(self):
self.assertEqual(gdal.GetConfigOption("GDAL_HTTP_PROXY"), "myproxyhostname.com")
self.assertEqual(gdal.GetConfigOption("GDAL_HTTP_PROXYUSERPWD"), "username")

def testSubSetStringEditable(self):
"""Test that a shapefile is editable after setting a subset"""
vl = QgsVectorLayer(TEST_DATA_DIR + '/' + 'lines.shp', 'subset_test', 'ogr')
self.assertTrue(vl.isValid())
self.assertTrue(vl.dataProvider().capabilities() & QgsVectorDataProvider.DeleteFeatures)

vl = QgsVectorLayer(TEST_DATA_DIR + '/' + 'lines.shp', 'subset_test', 'ogr')
vl.setSubsetString('')
self.assertTrue(vl.isValid())
self.assertTrue(vl.dataProvider().capabilities() & QgsVectorDataProvider.DeleteFeatures)

vl = QgsVectorLayer(TEST_DATA_DIR + '/' + 'lines.shp', 'subset_test', 'ogr')
vl.setSubsetString('"Name" = \'Arterial\'')
self.assertTrue(vl.isValid())
self.assertFalse(vl.dataProvider().capabilities() & QgsVectorDataProvider.DeleteFeatures)

vl.setSubsetString('')
self.assertTrue(vl.dataProvider().capabilities() & QgsVectorDataProvider.DeleteFeatures)


if __name__ == '__main__':
unittest.main()

0 comments on commit dd60fcd

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