Skip to content
Permalink
Browse files
adds test from #43582
  • Loading branch information
lbartoletti authored and nyalldawson committed Jun 21, 2021
1 parent 89b5097 commit 56052b68a903dfefdf7347b06694c87440d75c26
Showing with 14 additions and 3 deletions.
  1. +14 −3 tests/src/python/test_qgsgeometryvalidator.py
@@ -239,7 +239,7 @@ def test_ring_closed(self):
validator.run()
self.assertEqual(len(spy), 1)

self.assertEqual(spy[0][0].where(), QgsPointXY())
self.assertEqual(spy[0][0].where(), QgsPointXY(0, 0))
self.assertEqual(spy[0][0].what(), 'ring 0 not closed')

g = QgsGeometry.fromWkt("Polygon ((0 0, 10 0, 10 10, 0 0),(1 1, 2 1, 2 2, 1.1 1))")
@@ -249,7 +249,7 @@ def test_ring_closed(self):
validator.run()
self.assertEqual(len(spy), 1)

self.assertEqual(spy[0][0].where(), QgsPointXY())
self.assertEqual(spy[0][0].where(), QgsPointXY(1, 1))
self.assertEqual(spy[0][0].what(), 'ring 1 not closed')

g = QgsGeometry.fromWkt("Polygon ((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 2 1, 2 2, 1 1),(3 3, 3 4, 4 4, 3.1 3))")
@@ -259,9 +259,20 @@ def test_ring_closed(self):
validator.run()
self.assertEqual(len(spy), 1)

self.assertEqual(spy[0][0].where(), QgsPointXY())
self.assertEqual(spy[0][0].where(), QgsPointXY(3, 3))
self.assertEqual(spy[0][0].what(), 'ring 2 not closed')

# not closed but 2d close
g = QgsGeometry.fromWkt("POLYGONZ((1 1 0, 1 2 1, 2 2 2, 2 1 3, 1 1 4))")

validator = QgsGeometryValidator(g)
spy = QSignalSpy(validator.errorFound)
validator.run()
self.assertEqual(len(spy), 1)

self.assertEqual(spy[0][0].where(), QgsPointXY(1, 1))
self.assertEqual(spy[0][0].what(), 'ring 0 not closed, Z mismatch: 0 vs 4')


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

0 comments on commit 56052b6

Please sign in to comment.