summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2019-10-17 13:17:42 +0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-25 14:28:26 +0200
commit6bbf9a20e2c5865e01b537e8cd34dfca06621a4a (patch)
treea3e3ba68a165301704829ea18cb5a3156bba5670 /tests
parent24e540fbd71bd2b0843e751bde61ad0052a811b3 (diff)
Fixed #29770 -- Added LinearRing.is_counterclockwise property.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index a74eabb314..c2aca95178 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -5,7 +5,7 @@ import pickle
import random
from binascii import a2b_hex
from io import BytesIO
-from unittest import mock
+from unittest import mock, skipIf
from django.contrib.gis import gdal
from django.contrib.gis.geos import (
@@ -360,6 +360,32 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
line.reverse()
self.assertEqual(line.ewkt, 'SRID=4326;LINESTRING (151.2607 -33.887, 144.963 -37.8143)')
+ def _test_is_counterclockwise(self):
+ lr = LinearRing((0, 0), (1, 0), (0, 1), (0, 0))
+ self.assertIs(lr.is_counterclockwise, True)
+ lr.reverse()
+ self.assertIs(lr.is_counterclockwise, False)
+ msg = 'Orientation of an empty LinearRing cannot be determined.'
+ with self.assertRaisesMessage(ValueError, msg):
+ LinearRing().is_counterclockwise
+
+ @skipIf(geos_version_tuple() < (3, 7), 'GEOS >= 3.7.0 is required')
+ def test_is_counterclockwise(self):
+ self._test_is_counterclockwise()
+
+ @skipIf(geos_version_tuple() < (3, 7), 'GEOS >= 3.7.0 is required')
+ def test_is_counterclockwise_geos_error(self):
+ with mock.patch('django.contrib.gis.geos.prototypes.cs_is_ccw') as mocked:
+ mocked.return_value = 0
+ mocked.func_name = 'GEOSCoordSeq_isCCW'
+ msg = 'Error encountered in GEOS C function "GEOSCoordSeq_isCCW".'
+ with self.assertRaisesMessage(GEOSException, msg):
+ LinearRing((0, 0), (1, 0), (0, 1), (0, 0)).is_counterclockwise
+
+ @mock.patch('django.contrib.gis.geos.libgeos.geos_version', lambda: b'3.6.9')
+ def test_is_counterclockwise_fallback(self):
+ self._test_is_counterclockwise()
+
def test_multilinestring(self):
"Testing MultiLineString objects."
prev = fromstr('POINT(0 0)')