summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2025-12-28 08:07:11 -0500
committerGitHub <noreply@github.com>2025-12-28 14:07:11 +0100
commit4afe463950453b6d71f0c98f23fd0f1f2bd341bc (patch)
tree04d84e48d385a4e543e3c50ad0df420a4620fab8 /tests
parentda19b3897dc7c2e99b120d40322b36b4f1a09fe8 (diff)
Added some skips to GIS tests.
Also replaced some DatabaseFeatures.supports_<foo>_lookup attributes with @skipUnlessGISLookup.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/distapp/tests.py11
-rw-r--r--tests/gis_tests/geoapp/test_regress.py2
-rw-r--r--tests/gis_tests/geoapp/tests.py35
-rw-r--r--tests/gis_tests/relatedapp/tests.py3
4 files changed, 33 insertions, 18 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
index f8eae7ba37..8b0611f9ef 100644
--- a/tests/gis_tests/distapp/tests.py
+++ b/tests/gis_tests/distapp/tests.py
@@ -22,7 +22,7 @@ from django.db.models import (
)
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
-from ..utils import FuncTestMixin
+from ..utils import FuncTestMixin, skipUnlessGISLookup
from .models import (
AustraliaCity,
CensusZipcode,
@@ -65,7 +65,8 @@ class DistanceTest(TestCase):
self.assertEqual(1, Interstate.objects.count())
self.assertEqual(1, SouthTexasInterstate.objects.count())
- @skipUnlessDBFeature("supports_dwithin_lookup")
+ @skipUnlessGISLookup("dwithin")
+ @skipUnlessDBFeature("has_Transform_function")
def test_dwithin(self):
"""
Test the `dwithin` lookup type.
@@ -322,7 +323,8 @@ class DistanceTest(TestCase):
point__distance_lte=(Point(0, 0), D(m=100))
).exists()
- @skipUnlessDBFeature("supports_dwithin_lookup")
+ @skipUnlessGISLookup("dwithin")
+ @skipUnlessDBFeature("has_Transform_function")
def test_dwithin_subquery(self):
"""dwithin lookup in a subquery using OuterRef as a parameter."""
qs = CensusZipcode.objects.annotate(
@@ -334,7 +336,8 @@ class DistanceTest(TestCase):
).filter(annotated_value=True)
self.assertEqual(self.get_names(qs), ["77002", "77025", "77401"])
- @skipUnlessDBFeature("supports_dwithin_lookup", "supports_dwithin_distance_expr")
+ @skipUnlessGISLookup("dwithin")
+ @skipUnlessDBFeature("supports_dwithin_distance_expr")
def test_dwithin_with_expression_rhs(self):
# LineString of Wollongong and Adelaide coords.
ls = LineString(((150.902, -34.4245), (138.6, -34.9258)), srid=4326)
diff --git a/tests/gis_tests/geoapp/test_regress.py b/tests/gis_tests/geoapp/test_regress.py
index 8ac0ed3049..78f022b6aa 100644
--- a/tests/gis_tests/geoapp/test_regress.py
+++ b/tests/gis_tests/geoapp/test_regress.py
@@ -5,6 +5,7 @@ from django.contrib.gis.shortcuts import render_to_kmz
from django.db.models import Count, Min
from django.test import TestCase, skipUnlessDBFeature
+from ..utils import skipUnlessGISLookup
from .models import City, PennsylvaniaCity, State, Truth
@@ -66,6 +67,7 @@ class GeoRegressionTests(TestCase):
founded, PennsylvaniaCity.objects.aggregate(Min("founded"))["founded__min"]
)
+ @skipUnlessGISLookup("contains")
def test_empty_count(self):
"""
Testing that PostGISAdapter.__eq__ does check empty strings. See
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index 060ca723f8..7937a8bdc3 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -318,6 +318,7 @@ class SaveLoadTests(TestCase):
class GeoLookupTest(TestCase):
fixtures = ["initial"]
+ @skipUnlessGISLookup("disjoint")
def test_disjoint_lookup(self):
"Testing the `disjoint` lookup type."
ptown = City.objects.get(name="Pueblo")
@@ -327,22 +328,22 @@ class GeoLookupTest(TestCase):
self.assertEqual(1, qs2.count())
self.assertEqual("Kansas", qs2[0].name)
- def test_contains_contained_lookups(self):
- "Testing the 'contained', 'contains', and 'bbcontains' lookup types."
+ @skipUnlessGISLookup("contained")
+ def test_contained(self):
# Getting Texas, yes we were a country -- once ;)
texas = Country.objects.get(name="Texas")
# Seeing what cities are in Texas, should get Houston and Dallas,
# and Oklahoma City because 'contained' only checks on the
# _bounding box_ of the Geometries.
- if connection.features.supports_contained_lookup:
- qs = City.objects.filter(point__contained=texas.mpoly)
- self.assertEqual(3, qs.count())
- cities = ["Houston", "Dallas", "Oklahoma City"]
- for c in qs:
- self.assertIn(c.name, cities)
+ qs = City.objects.filter(point__contained=texas.mpoly)
+ self.assertEqual(3, qs.count())
+ cities = ["Houston", "Dallas", "Oklahoma City"]
+ for c in qs:
+ self.assertIn(c.name, cities)
- # Pulling out some cities.
+ @skipUnlessGISLookup("contains")
+ def test_contains(self):
houston = City.objects.get(name="Houston")
wellington = City.objects.get(name="Wellington")
pueblo = City.objects.get(name="Pueblo")
@@ -371,13 +372,15 @@ class GeoLookupTest(TestCase):
len(Country.objects.filter(mpoly__contains=okcity.point.wkt)), 0
) # Query w/WKT
+ @skipUnlessGISLookup("bbcontains")
+ def test_bbcontains(self):
# OK City is contained w/in bounding box of Texas.
- if connection.features.supports_bbcontains_lookup:
- qs = Country.objects.filter(mpoly__bbcontains=okcity.point)
- self.assertEqual(1, len(qs))
- self.assertEqual("Texas", qs[0].name)
+ okcity = City.objects.get(name="Oklahoma City")
+ qs = Country.objects.filter(mpoly__bbcontains=okcity.point)
+ self.assertEqual(1, len(qs))
+ self.assertEqual("Texas", qs[0].name)
- @skipUnlessDBFeature("supports_crosses_lookup")
+ @skipUnlessGISLookup("crosses")
def test_crosses_lookup(self):
Track.objects.create(name="Line1", line=LineString([(-95, 29), (-60, 0)]))
self.assertEqual(
@@ -470,6 +473,7 @@ class GeoLookupTest(TestCase):
lambda b: b.name,
)
+ @skipUnlessGISLookup("same_as", "equals")
def test_equals_lookups(self):
"Testing the 'same_as' and 'equals' lookup types."
pnt = fromstr("POINT (-95.363151 29.763374)", srid=4326)
@@ -658,6 +662,7 @@ class GeoLookupTest(TestCase):
)
)
+ @skipUnlessDBFeature("has_Union_function")
def test_gis_lookups_with_complex_expressions(self):
multiple_arg_lookups = {
"dwithin",
@@ -671,6 +676,7 @@ class GeoLookupTest(TestCase):
**{"point__" + lookup: functions.Union("point", "point")}
).exists()
+ @skipUnlessGISLookup("within")
def test_subquery_annotation(self):
multifields = MultiFields.objects.create(
city=City.objects.create(point=Point(1, 1)),
@@ -825,6 +831,7 @@ class GeoQuerySetTest(TestCase):
Union("point", tolerance="0.05))), (((1"),
)
+ @skipUnlessGISLookup("within")
def test_within_subquery(self):
"""
Using a queryset inside a geo lookup is working (using a subquery)
diff --git a/tests/gis_tests/relatedapp/tests.py b/tests/gis_tests/relatedapp/tests.py
index 8baf65be27..99294f3c50 100644
--- a/tests/gis_tests/relatedapp/tests.py
+++ b/tests/gis_tests/relatedapp/tests.py
@@ -6,6 +6,7 @@ from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import override_settings
from django.utils import timezone
+from ..utils import skipUnlessGISLookup
from .models import Article, Author, Book, City, DirectoryEntry, Event, Location, Parcel
@@ -117,6 +118,7 @@ class RelatedGeoModelTest(TestCase):
# Regression test for #9752.
list(DirectoryEntry.objects.select_related())
+ @skipUnlessGISLookup("within")
def test06_f_expressions(self):
"Testing F() expressions on GeometryFields."
# Constructing a dummy parcel border and getting the City instance for
@@ -229,6 +231,7 @@ class RelatedGeoModelTest(TestCase):
self.assertEqual(val_dict["id"], c_id)
self.assertEqual(val_dict["location__id"], l_id)
+ @skipUnlessGISLookup("within")
def test10_combine(self):
"Testing the combination of two QuerySets (#10807)."
buf1 = City.objects.get(name="Aurora").location.point.buffer(0.1)