MCPcopy
hub / github.com/django/django / test_db_selection

Method test_db_selection

tests/multiple_database/tests.py:22–30  ·  view source on GitHub ↗

Querysets will use the default database by default

(self)

Source from the content-addressed store, hash-verified

20 databases = {"default", "other"}
21
22 def test_db_selection(self):
23 "Querysets will use the default database by default"
24 self.assertEqual(Book.objects.db, DEFAULT_DB_ALIAS)
25 self.assertEqual(Book.objects.all().db, DEFAULT_DB_ALIAS)
26
27 self.assertEqual(Book.objects.using("other").db, "other")
28
29 self.assertEqual(Book.objects.db_manager("other").db, "other")
30 self.assertEqual(Book.objects.db_manager("other").all().db, "other")
31
32 def test_default_creation(self):
33 """

Callers

nothing calls this directly

Calls 3

db_managerMethod · 0.80
allMethod · 0.45
usingMethod · 0.45

Tested by

no test coverage detected