1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #33476 -- Reformatted code with Black.

This commit is contained in:
django-bot
2022-02-03 20:24:19 +01:00
committed by Mariusz Felisiak
parent f68fa8b45d
commit 9c19aff7c7
1992 changed files with 139577 additions and 96284 deletions

View File

@@ -9,25 +9,25 @@ class TestRouter:
"""
Routes to the 'other' database if the model name starts with 'Other'.
"""
def allow_migrate(self, db, app_label, model_name=None, **hints):
return db == ('other' if model_name.startswith('other') else 'default')
return db == ("other" if model_name.startswith("other") else "default")
@override_settings(DATABASE_ROUTERS=[TestRouter()])
@isolate_apps('check_framework')
@isolate_apps("check_framework")
class TestMultiDBChecks(SimpleTestCase):
def _patch_check_field_on(self, db):
return mock.patch.object(connections[db].validation, 'check_field')
return mock.patch.object(connections[db].validation, "check_field")
def test_checks_called_on_the_default_database(self):
class Model(models.Model):
field = models.CharField(max_length=100)
model = Model()
with self._patch_check_field_on('default') as mock_check_field_default:
with self._patch_check_field_on('other') as mock_check_field_other:
model.check(databases={'default', 'other'})
with self._patch_check_field_on("default") as mock_check_field_default:
with self._patch_check_field_on("other") as mock_check_field_other:
model.check(databases={"default", "other"})
self.assertTrue(mock_check_field_default.called)
self.assertFalse(mock_check_field_other.called)
@@ -36,8 +36,8 @@ class TestMultiDBChecks(SimpleTestCase):
field = models.CharField(max_length=100)
model = OtherModel()
with self._patch_check_field_on('other') as mock_check_field_other:
with self._patch_check_field_on('default') as mock_check_field_default:
model.check(databases={'default', 'other'})
with self._patch_check_field_on("other") as mock_check_field_other:
with self._patch_check_field_on("default") as mock_check_field_default:
model.check(databases={"default", "other"})
self.assertTrue(mock_check_field_other.called)
self.assertFalse(mock_check_field_default.called)