summaryrefslogtreecommitdiff
path: root/tests/gis_tests/geoapp/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gis_tests/geoapp/tests.py')
-rw-r--r--tests/gis_tests/geoapp/tests.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index 47d16434a5..be007041a5 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -9,7 +9,7 @@ from django.contrib.gis.geos import (
MultiPoint, MultiPolygon, Point, Polygon, fromstr,
)
from django.core.management import call_command
-from django.db import NotSupportedError, connection
+from django.db import DatabaseError, NotSupportedError, connection
from django.test import TestCase, skipUnlessDBFeature
from ..utils import (
@@ -564,6 +564,42 @@ class GeoQuerySetTest(TestCase):
qs = City.objects.filter(name='NotACity')
self.assertIsNone(qs.aggregate(Union('point'))['point__union'])
+ @unittest.skipUnless(
+ connection.vendor == 'oracle',
+ 'Oracle supports tolerance paremeter.',
+ )
+ def test_unionagg_tolerance(self):
+ City.objects.create(
+ point=fromstr('POINT(-96.467222 32.751389)', srid=4326),
+ name='Forney',
+ )
+ tx = Country.objects.get(name='Texas').mpoly
+ # Tolerance is greater than distance between Forney and Dallas, that's
+ # why Dallas is ignored.
+ forney_houston = GEOSGeometry(
+ 'MULTIPOINT(-95.363151 29.763374, -96.467222 32.751389)',
+ srid=4326,
+ )
+ self.assertIs(
+ forney_houston.equals(
+ City.objects.filter(point__within=tx).aggregate(
+ Union('point', tolerance=32000),
+ )['point__union'],
+ ),
+ True,
+ )
+
+ @unittest.skipUnless(
+ connection.vendor == 'oracle',
+ 'Oracle supports tolerance paremeter.',
+ )
+ def test_unionagg_tolerance_escaping(self):
+ tx = Country.objects.get(name='Texas').mpoly
+ with self.assertRaises(DatabaseError):
+ City.objects.filter(point__within=tx).aggregate(
+ Union('point', tolerance='0.05))), (((1'),
+ )
+
def test_within_subquery(self):
"""
Using a queryset inside a geo lookup is working (using a subquery)