summaryrefslogtreecommitdiff
path: root/tests/multiple_database
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-04 08:08:27 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch)
treefa50869f5614295f462d9bf77fec59365c621609 /tests/multiple_database
parent9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff)
downloaddjango-7119f40c9881666b6f9b5cf7df09ee1d21cc8344.tar.gz
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'tests/multiple_database')
-rw-r--r--tests/multiple_database/tests.py53
1 files changed, 40 insertions, 13 deletions
diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py
index 3f5548d761..2dc894b858 100644
--- a/tests/multiple_database/tests.py
+++ b/tests/multiple_database/tests.py
@@ -216,7 +216,8 @@ class QueryTestCase(TestCase):
dive = Book.objects.using("other").get(title="Dive into Python")
mark = Person.objects.using("other").get(name="Mark Pilgrim")
- # Retrieve related object by descriptor. Related objects should be database-bound
+ # Retrieve related object by descriptor. Related objects should be
+ # database-bound.
self.assertEqual(
list(dive.authors.all().values_list("name", flat=True)), ["Mark Pilgrim"]
)
@@ -597,7 +598,8 @@ class QueryTestCase(TestCase):
chris = Person.objects.using("other").get(name="Chris Mills")
dive = Book.objects.using("other").get(title="Dive into Python")
- # Retrieve related object by descriptor. Related objects should be database-bound
+ # Retrieve related object by descriptor. Related objects should be
+ # database-bound.
self.assertEqual(
list(chris.edited.values_list("title", flat=True)), ["Dive into Python"]
)
@@ -743,7 +745,10 @@ class QueryTestCase(TestCase):
marty.edited.add(dive)
def test_foreign_key_deletion(self):
- "Cascaded deletions of Foreign Key relations issue queries on the right database"
+ """
+ Cascaded deletions of Foreign Key relations issue queries on the right
+ database.
+ """
mark = Person.objects.using("other").create(name="Mark Pilgrim")
Pet.objects.using("other").create(name="Fido", owner=mark)
@@ -843,7 +848,8 @@ class QueryTestCase(TestCase):
alice_profile = UserProfile.objects.using("default").get(flavor="chocolate")
bob_profile = UserProfile.objects.using("other").get(flavor="crunchy frog")
- # Retrieve related object by descriptor. Related objects should be database-bound
+ # Retrieve related object by descriptor. Related objects should be
+ # database-bound.
self.assertEqual(alice_profile.user.username, "alice")
self.assertEqual(bob_profile.user.username, "bob")
@@ -976,7 +982,8 @@ class QueryTestCase(TestCase):
# Reget the objects to clear caches
dive = Book.objects.using("other").get(title="Dive into Python")
- # Retrieve related object by descriptor. Related objects should be database-bound
+ # Retrieve related object by descriptor. Related objects should be
+ # database-bound.
self.assertEqual(
list(dive.reviews.all().values_list("source", flat=True)), ["Python Weekly"]
)
@@ -1090,7 +1097,10 @@ class QueryTestCase(TestCase):
)
def test_generic_key_cross_database_protection(self):
- "Operations that involve sharing generic key objects across databases raise an error"
+ """
+ Operations that involve sharing generic key objects across databases
+ raise an error.
+ """
# Create a book and author on the default database
pro = Book.objects.create(
title="Pro Django", published=datetime.date(2008, 12, 16)
@@ -1171,7 +1181,10 @@ class QueryTestCase(TestCase):
)
def test_generic_key_deletion(self):
- "Cascaded deletions of Generic Key relations issue queries on the right database"
+ """
+ Cascaded deletions of Generic Key relations issue queries on the right
+ database.
+ """
dive = Book.objects.using("other").create(
title="Dive into Python", published=datetime.date(2009, 5, 4)
)
@@ -1223,7 +1236,10 @@ class QueryTestCase(TestCase):
self.assertQuerysetEqual(val, [dive.pk], attrgetter("pk"))
def test_select_related(self):
- "Database assignment is retained if an object is retrieved with select_related()"
+ """
+ Database assignment is retained if an object is retrieved with
+ select_related().
+ """
# Create a book and author on the other database
mark = Person.objects.using("other").create(name="Mark Pilgrim")
Book.objects.using("other").create(
@@ -1465,7 +1481,10 @@ class RouterTestCase(TestCase):
published=datetime.date(2009, 5, 4),
)
# Set a foreign key set with an object from a different database
- msg = "<Book: Dive into Python> instance isn't saved. Use bulk=False or save the object first."
+ msg = (
+ "<Book: Dive into Python> instance isn't saved. Use bulk=False or save the "
+ "object first."
+ )
with self.assertRaisesMessage(ValueError, msg):
marty.edited.set([dive])
@@ -1508,7 +1527,8 @@ class RouterTestCase(TestCase):
# Set a foreign key set with an object from a different database
marty.edited.set([pro, dive], bulk=False)
- # Assignment implies a save, so database assignments of original objects have changed...
+ # Assignment implies a save, so database assignments of original
+ # objects have changed...
self.assertEqual(marty._state.db, "default")
self.assertEqual(pro._state.db, "default")
self.assertEqual(dive._state.db, "default")
@@ -1524,7 +1544,8 @@ class RouterTestCase(TestCase):
# Add to a foreign key set with an object from a different database
marty.edited.add(dive, bulk=False)
- # Add implies a save, so database assignments of original objects have changed...
+ # Add implies a save, so database assignments of original objects have
+ # changed...
self.assertEqual(marty._state.db, "default")
self.assertEqual(pro._state.db, "default")
self.assertEqual(dive._state.db, "default")
@@ -1813,7 +1834,10 @@ class RouterTestCase(TestCase):
self.assertEqual(marty.book_set.db_manager("default").all().db, "default")
def test_foreign_key_managers(self):
- "FK reverse relations are represented by managers, and can be controlled like managers"
+ """
+ FK reverse relations are represented by managers, and can be controlled
+ like managers.
+ """
marty = Person.objects.using("other").create(pk=1, name="Marty Alchin")
Book.objects.using("other").create(
pk=1,
@@ -1826,7 +1850,10 @@ class RouterTestCase(TestCase):
self.assertEqual(marty.edited.db_manager("default").all().db, "default")
def test_generic_key_managers(self):
- "Generic key relations are represented by managers, and can be controlled like managers"
+ """
+ Generic key relations are represented by managers, and can be
+ controlled like managers.
+ """
pro = Book.objects.using("other").create(
title="Pro Django", published=datetime.date(2008, 12, 16)
)