Skip to content
Permalink
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/TestData.py
  2. +15 −1 python/plugins/processing/tests/ToolsTest.py
@@ -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 processing.tools 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([f.id() 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)
try:
features = vector.features(test_layer_invalid_geoms)
features = [f for f in features]
self.fail()

This comment has been minimized.

Copy link
@rldhont

rldhont Jan 9, 2017

Contributor

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

except GeoAlgorithmExecutionException:
pass

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


def testValues(self):
ProcessingConfig.initialize()

4 comments on commit 3067648

@rldhont

This comment has been minimized.

Copy link
Contributor

@rldhont rldhont replied Jan 9, 2017

global name 'GeoAlgorithmExecutionException' is not defined!
https://travis-ci.org/qgis/QGIS/builds/190244003

@alexbruy

This comment has been minimized.

Copy link
Contributor

@alexbruy alexbruy replied Jan 9, 2017

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

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson replied Jan 9, 2017

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

@volaya

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.
You can’t perform that action at this time.