diff --git a/boundaries/tests/test_boundary.py b/boundaries/tests/test_boundary.py index f79ce07..3770d46 100644 --- a/boundaries/tests/test_boundary.py +++ b/boundaries/tests/test_boundary.py @@ -135,5 +135,11 @@ def test_unary_union(self): boundary = Boundary(shape='MULTIPOLYGON (((0 0,0 5,2.5 5.0001,5 5,0 0)))') boundary.unary_union(Geometry(OGRGeometry('MULTIPOLYGON (((0 0,5 0,5 5,0 0)))'))) - self.assertEqual(boundary.shape.ogr.wkt, 'MULTIPOLYGON (((5 5,5 0,0 0,0 5,2.5 5.0001,5 5)))') - self.assertEqual(boundary.simple_shape.ogr.wkt, 'MULTIPOLYGON (((5 5,5 0,0 0,0 5,5 5)))') + self.assertEqual( + boundary.shape.ogr.difference(OGRGeometry('MULTIPOLYGON (((5 5,5 0,0 0,0 5,2.5 5.0001,5 5)))')).wkt, + 'POLYGON EMPTY', + ) + self.assertEqual( + boundary.simple_shape.ogr.difference(OGRGeometry('MULTIPOLYGON (((5 5,5 0,0 0,0 5,5 5)))')).wkt, + 'POLYGON EMPTY', + ) diff --git a/boundaries/tests/test_geometry.py b/boundaries/tests/test_geometry.py index 6c4e671..a4942e2 100644 --- a/boundaries/tests/test_geometry.py +++ b/boundaries/tests/test_geometry.py @@ -44,7 +44,10 @@ def test_unary_union(self): geometry = Geometry(OGRGeometry('MULTIPOLYGON (((0 0,0 5,5 5,0 0)),((0 0,5 0,5 5,0 0)))')).unary_union() self.assertIsInstance(geometry, Geometry) self.assertEqual(geometry.geometry.geom_name, 'MULTIPOLYGON') - self.assertEqual(geometry.wkt, 'MULTIPOLYGON (((0 0,0 5,5 5,5 0,0 0)))') + self.assertEqual( + geometry.geometry.difference(OGRGeometry('MULTIPOLYGON (((0 0,0 5,5 5,5 0,0 0)))')).wkt, + 'POLYGON EMPTY', + ) def test_merge_with_ogrgeometry(self): other = OGRGeometry('MULTIPOLYGON (((5 0,5 3,2 0,5 0)))') diff --git a/boundaries/tests/test_loadshapefiles.py b/boundaries/tests/test_loadshapefiles.py index 9cf508c..44a3397 100644 --- a/boundaries/tests/test_loadshapefiles.py +++ b/boundaries/tests/test_loadshapefiles.py @@ -5,6 +5,7 @@ from datetime import date from zipfile import BadZipfile +from django.contrib.gis.gdal import OGRGeometry from django.core.management import call_command from django.test import TestCase from testfixtures import LogCapture @@ -196,12 +197,9 @@ def test_union_merge_strategy(self): Command().load_boundary(self.feature, 'invalid') boundary = Command().load_boundary(self.feature, 'union') - try: # Django < 2.2 - self.assertEqual(boundary.shape.ogr.wkt, 'MULTIPOLYGON (((0.0001 0.0001,0 5,0 5,0 5,5 5,5 5,0.0001 0.0001)))') - self.assertEqual(boundary.simple_shape.ogr.wkt, 'MULTIPOLYGON (((0.0001 0.0001,0 5,5 5,5 5,0.0001 0.0001)))') - except AssertionError: - self.assertEqual(boundary.shape.ogr.wkt, 'MULTIPOLYGON (((0.0001 0.0001,0 5,5 5,0.0001 0.0001)))') - self.assertEqual(boundary.simple_shape.ogr.wkt, 'MULTIPOLYGON (((0.0001 0.0001,0 5,5 5,0.0001 0.0001)))') + expected = OGRGeometry('MULTIPOLYGON (((0.0001 0.0001,0 5,5 5,0.0001 0.0001)))') + self.assertEqual(boundary.shape.ogr.difference(expected).wkt, 'POLYGON EMPTY') + self.assertEqual(boundary.simple_shape.ogr.difference(expected).wkt, 'POLYGON EMPTY') self.assertRegex(boundary.centroid.ogr.wkt, r'\APOINT \(1\.6667 3\.3333666666666+7\)\Z') self.assertEqual(boundary.extent, (0.0, 0.0001, 5.0, 5.0))