mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Refs #32233 -- Added tests for nonexistent cache and databases aliases.
This commit is contained in:
@@ -3,7 +3,9 @@ import unittest
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import DEFAULT_DB_ALIAS, ProgrammingError, connection
|
||||
from django.db.utils import ConnectionHandler, load_backend
|
||||
from django.db.utils import (
|
||||
ConnectionDoesNotExist, ConnectionHandler, load_backend,
|
||||
)
|
||||
from django.test import SimpleTestCase, TestCase
|
||||
|
||||
|
||||
@@ -38,6 +40,30 @@ class ConnectionHandlerTests(SimpleTestCase):
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg):
|
||||
conns['other'].ensure_connection()
|
||||
|
||||
def test_nonexistent_alias(self):
|
||||
msg = "The connection nonexistent doesn't exist"
|
||||
conns = ConnectionHandler({
|
||||
DEFAULT_DB_ALIAS: {'ENGINE': 'django.db.backends.dummy'},
|
||||
})
|
||||
with self.assertRaisesMessage(ConnectionDoesNotExist, msg):
|
||||
conns['nonexistent']
|
||||
|
||||
def test_ensure_defaults_nonexistent_alias(self):
|
||||
msg = "The connection nonexistent doesn't exist"
|
||||
conns = ConnectionHandler({
|
||||
DEFAULT_DB_ALIAS: {'ENGINE': 'django.db.backends.dummy'},
|
||||
})
|
||||
with self.assertRaisesMessage(ConnectionDoesNotExist, msg):
|
||||
conns.ensure_defaults('nonexistent')
|
||||
|
||||
def test_prepare_test_settings_nonexistent_alias(self):
|
||||
msg = "The connection nonexistent doesn't exist"
|
||||
conns = ConnectionHandler({
|
||||
DEFAULT_DB_ALIAS: {'ENGINE': 'django.db.backends.dummy'},
|
||||
})
|
||||
with self.assertRaisesMessage(ConnectionDoesNotExist, msg):
|
||||
conns.prepare_test_settings('nonexistent')
|
||||
|
||||
|
||||
class DatabaseErrorWrapperTests(TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user