summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2016-09-08 13:33:36 -0700
committerTim Graham <timograham@gmail.com>2016-09-08 16:33:36 -0400
commit7ca3b391b611eb710c4c1d613e2f672591097a00 (patch)
tree92dad21e80ae5d20fd35645395dac95d4bc37041 /tests
parent0bbab97c289ebcfd5676d4c84686c5549e650f8d (diff)
Fixed #27170 -- Added DatabaseWrapper class attributes to ease subclassing.
Diffstat (limited to 'tests')
-rw-r--r--tests/backends/tests.py25
-rw-r--r--tests/test_runner/tests.py6
2 files changed, 28 insertions, 3 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 4851995149..106fd7f856 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -32,6 +32,31 @@ from django.utils.six.moves import range
from . import models
+class DatabaseWrapperTests(SimpleTestCase):
+
+ def test_initialization_class_attributes(self):
+ """
+ The "initialization" class attributes like client_class and
+ creation_class should be set on the class and reflected in the
+ corresponding instance attributes of the instantiated backend.
+ """
+ conn = connections[DEFAULT_DB_ALIAS]
+ conn_class = type(conn)
+ attr_names = [
+ ('client_class', 'client'),
+ ('creation_class', 'creation'),
+ ('features_class', 'features'),
+ ('introspection_class', 'introspection'),
+ ('ops_class', 'ops'),
+ ('validation_class', 'validation'),
+ ]
+ for class_attr_name, instance_attr_name in attr_names:
+ class_attr_value = getattr(conn_class, class_attr_name)
+ self.assertIsNotNone(class_attr_value)
+ instance_attr_value = getattr(conn, instance_attr_name)
+ self.assertIsInstance(instance_attr_value, class_attr_value)
+
+
class DummyBackendTest(SimpleTestCase):
def test_no_databases(self):
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py
index c2ad07013c..15417db645 100644
--- a/tests/test_runner/tests.py
+++ b/tests/test_runner/tests.py
@@ -281,7 +281,7 @@ class SetupDatabasesTests(unittest.TestCase):
}
})
- with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
+ with mock.patch('django.db.backends.dummy.base.DatabaseWrapper.creation_class') as mocked_db_creation:
with mock.patch('django.test.utils.connections', new=tested_connections):
old_config = self.runner_instance.setup_databases()
self.runner_instance.teardown_databases(old_config)
@@ -306,7 +306,7 @@ class SetupDatabasesTests(unittest.TestCase):
'ENGINE': 'django.db.backends.dummy',
},
})
- with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
+ with mock.patch('django.db.backends.dummy.base.DatabaseWrapper.creation_class') as mocked_db_creation:
with mock.patch('django.test.utils.connections', new=tested_connections):
self.runner_instance.setup_databases()
mocked_db_creation.return_value.create_test_db.assert_called_once_with(
@@ -320,7 +320,7 @@ class SetupDatabasesTests(unittest.TestCase):
'TEST': {'SERIALIZE': False},
},
})
- with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
+ with mock.patch('django.db.backends.dummy.base.DatabaseWrapper.creation_class') as mocked_db_creation:
with mock.patch('django.test.utils.connections', new=tested_connections):
self.runner_instance.setup_databases()
mocked_db_creation.return_value.create_test_db.assert_called_once_with(