Skip to content
Browse files
[processing] added test for invalid geometry checking
  • Loading branch information
volaya authored and alexbruy committed Jan 9, 2017
1 parent 7b68c77 commit 306764871baab544f9566b327d2188a5b1fc8938
Showing with 19 additions and 1 deletion.
  1. +4 −0 python/plugins/processing/tests/
  2. +15 −1 python/plugins/processing/tests/
@@ -36,3 +36,7 @@ def table():

def points():
return os.path.join(testDataPath, 'points.gml')

def invalid_geometries():
return os.path.join(testDataPath, 'invalidgeometries.gml')

@@ -33,7 +33,7 @@
from qgis.testing import start_app, unittest

from processing.core.ProcessingConfig import ProcessingConfig
from processing.tests.TestData import testDataPath, points
from processing.tests.TestData import testDataPath, points, invalid_geometries
from import vector

testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
@@ -98,7 +98,21 @@ def testFeatures(self):
features = vector.features(test_layer, QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry))
self.assertEqual(set([ for f in features]), set([2, 4, 6]))

#test exception is raised when filtering invalid geoms
test_layer_invalid_geoms = QgsVectorLayer(invalid_geometries(), 'test', 'ogr')

previous_value_invalid_geoms = ProcessingConfig.getSetting(ProcessingConfig.FILTER_INVALID_GEOMETRIES)
ProcessingConfig.setSettingValue(ProcessingConfig.FILTER_INVALID_GEOMETRIES, 2)
features = vector.features(test_layer_invalid_geoms)
features = [f for f in features]

This comment has been minimized.

Copy link

rldhont Jan 9, 2017


@volaya the test fails here. Does this code have to fail at vector.feature ?

except GeoAlgorithmExecutionException:

ProcessingConfig.setSettingValue(ProcessingConfig.FILTER_INVALID_GEOMETRIES, previous_value_invalid_geoms)
ProcessingConfig.setSettingValue(ProcessingConfig.USE_SELECTED, previous_value)

def testValues(self):

4 comments on commit 3067648


This comment has been minimized.

Copy link

@rldhont rldhont replied Jan 9, 2017

global name 'GeoAlgorithmExecutionException' is not defined!


This comment has been minimized.

Copy link

@alexbruy alexbruy replied Jan 9, 2017

Interesting, it passed locally. Missed import should be fixed now


This comment has been minimized.

Copy link

@nyalldawson nyalldawson replied Jan 9, 2017

@volaya I've reverted this test for now due to failures on Travis


This comment has been minimized.

Copy link
Contributor Author

@volaya volaya replied Jan 10, 2017

@nyalldawson Thanks for that. I was a bit puzzled with the test. The test data has a self-intersecting polygon, so that should be signaled as an invalid geometry and an error raised. However, the polygons is skipped, because the isGeosEmpty() method returns true for that geometry... The geometry is wrong, but not empty. Am I missing something, or that might be some error on the core geometry class?

Please sign in to comment.