summaryrefslogtreecommitdiff
path: root/tests/gis_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-02-21 08:42:28 +0100
committerGitHub <noreply@github.com>2023-02-21 08:42:28 +0100
commit5afd8c69404d718d254399fb5804efe0aa24fa8a (patch)
tree175830c26f4658ce2a7d08bdf68fba01b2dbe437 /tests/gis_tests
parent6cbc403b8ee7014bd6dae4892d404eedb1d4a50d (diff)
downloaddjango-5afd8c69404d718d254399fb5804efe0aa24fa8a.tar.gz
Refs #16969 -- Added test for not initializing PostGIS-specific stuff for non-db connections.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r--tests/gis_tests/tests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/gis_tests/tests.py b/tests/gis_tests/tests.py
index 9da2b4df99..ba084c636d 100644
--- a/tests/gis_tests/tests.py
+++ b/tests/gis_tests/tests.py
@@ -2,6 +2,7 @@ import unittest
from django.core.exceptions import ImproperlyConfigured
from django.db import ProgrammingError
+from django.db.backends.base.base import NO_DB_ALIAS
try:
from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
@@ -83,3 +84,18 @@ class TestPostGISVersionCheck(unittest.TestCase):
ops = FakePostGISOperations()
with self.assertRaises(ImproperlyConfigured):
ops.spatial_version
+
+
+@unittest.skipUnless(HAS_POSTGRES, "PostGIS-specific tests.")
+class TestPostGISBackend(unittest.TestCase):
+ def test_non_db_connection_classes(self):
+ from django.contrib.gis.db.backends.postgis.base import DatabaseWrapper
+ from django.db.backends.postgresql.features import DatabaseFeatures
+ from django.db.backends.postgresql.introspection import DatabaseIntrospection
+ from django.db.backends.postgresql.operations import DatabaseOperations
+
+ wrapper = DatabaseWrapper(settings_dict={}, alias=NO_DB_ALIAS)
+ # PostGIS-specific stuff is not initialized for non-db connections.
+ self.assertIs(wrapper.features_class, DatabaseFeatures)
+ self.assertIs(wrapper.ops_class, DatabaseOperations)
+ self.assertIs(wrapper.introspection_class, DatabaseIntrospection)