mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Refs #16969 -- Added test for not initializing PostGIS-specific stuff for non-db connections.
This commit is contained in:
parent
6cbc403b8e
commit
5afd8c6940
@ -2,6 +2,7 @@ import unittest
|
|||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import ProgrammingError
|
from django.db import ProgrammingError
|
||||||
|
from django.db.backends.base.base import NO_DB_ALIAS
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
|
from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
|
||||||
@ -83,3 +84,18 @@ class TestPostGISVersionCheck(unittest.TestCase):
|
|||||||
ops = FakePostGISOperations()
|
ops = FakePostGISOperations()
|
||||||
with self.assertRaises(ImproperlyConfigured):
|
with self.assertRaises(ImproperlyConfigured):
|
||||||
ops.spatial_version
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user