diff options
| author | Tim Graham <timograham@gmail.com> | 2025-06-05 16:18:56 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-05 22:18:56 +0200 |
| commit | cf1a80fc2d19f359744a20bb6cb1f0a169ef506b (patch) | |
| tree | 25e40d62be4a050fcba26bdddc3eae41313190fd /tests/gis_tests | |
| parent | f0a87895ffaf6532a22143b5e2e304c59b7958ae (diff) | |
Added validation to BaseSpatialFeatures.has_<Func>_function.
Diffstat (limited to 'tests/gis_tests')
| -rw-r--r-- | tests/gis_tests/geoapp/test_functions.py | 4 | ||||
| -rw-r--r-- | tests/gis_tests/tests.py | 13 |
2 files changed, 14 insertions, 3 deletions
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 3e881b41dc..9844905200 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -559,7 +559,7 @@ class GISFunctionsTests(FuncTestMixin, TestCase): # Exact value depends on database and version. self.assertTrue(20 <= ptown.size <= 105) - @skipUnlessDBFeature("has_NumGeom_function") + @skipUnlessDBFeature("has_NumGeometries_function") def test_num_geom(self): # Both 'countries' only have two geometries. for c in Country.objects.annotate(num_geom=functions.NumGeometries("mpoly")): @@ -576,7 +576,7 @@ class GISFunctionsTests(FuncTestMixin, TestCase): else: self.assertEqual(1, city.num_geom) - @skipUnlessDBFeature("has_NumPoint_function") + @skipUnlessDBFeature("has_NumPoints_function") def test_num_points(self): coords = [(-95.363151, 29.763374), (-95.448601, 29.713803)] Track.objects.create(name="Foo", line=LineString(coords)) diff --git a/tests/gis_tests/tests.py b/tests/gis_tests/tests.py index ba084c636d..b852ffe789 100644 --- a/tests/gis_tests/tests.py +++ b/tests/gis_tests/tests.py @@ -1,8 +1,9 @@ import unittest from django.core.exceptions import ImproperlyConfigured -from django.db import ProgrammingError +from django.db import ProgrammingError, connection from django.db.backends.base.base import NO_DB_ALIAS +from django.test import TestCase try: from django.contrib.gis.db.backends.postgis.operations import PostGISOperations @@ -12,6 +13,16 @@ except ImportError: HAS_POSTGRES = False +class BaseSpatialFeaturesTests(TestCase): + def test_invalid_has_func_function(self): + msg = ( + 'DatabaseFeatures.has_Invalid_function isn\'t valid. Is "Invalid" ' + "missing from BaseSpatialOperations.unsupported_functions?" + ) + with self.assertRaisesMessage(ValueError, msg): + connection.features.has_Invalid_function + + if HAS_POSTGRES: class FakeConnection: |
