diff options
| author | django-bot <ops@djangoproject.com> | 2022-02-08 12:09:55 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-08 12:15:38 +0100 |
| commit | 6a682b38e75d4c975b4c4493565a59f1bc14397c (patch) | |
| tree | 0bd9cda550bea26238656d9f120d769e8b41bb9e /tests/multiple_database/routers.py | |
| parent | e73ce08888e6f34d3f050377cfd2fbb733be94a9 (diff) | |
[4.0.x] Refs #33476 -- Reformatted code with Black.
Backport of 9c19aff7c7561e3a82978a272ecdaad40dda5c00 from main.
Diffstat (limited to 'tests/multiple_database/routers.py')
| -rw-r--r-- | tests/multiple_database/routers.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/multiple_database/routers.py b/tests/multiple_database/routers.py index 7891e22969..0cc7f1729c 100644 --- a/tests/multiple_database/routers.py +++ b/tests/multiple_database/routers.py @@ -9,14 +9,17 @@ class TestRouter: def db_for_read(self, model, instance=None, **hints): if instance: - return instance._state.db or 'other' - return 'other' + return instance._state.db or "other" + return "other" def db_for_write(self, model, **hints): return DEFAULT_DB_ALIAS def allow_relation(self, obj1, obj2, **hints): - return obj1._state.db in ('default', 'other') and obj2._state.db in ('default', 'other') + return obj1._state.db in ("default", "other") and obj2._state.db in ( + "default", + "other", + ) def allow_migrate(self, db, app_label, **hints): return True @@ -29,30 +32,30 @@ class AuthRouter: def db_for_read(self, model, **hints): "Point all read operations on auth models to 'default'" - if model._meta.app_label == 'auth': + if model._meta.app_label == "auth": # We use default here to ensure we can tell the difference # between a read request and a write request for Auth objects - return 'default' + return "default" return None def db_for_write(self, model, **hints): "Point all operations on auth models to 'other'" - if model._meta.app_label == 'auth': - return 'other' + if model._meta.app_label == "auth": + return "other" return None def allow_relation(self, obj1, obj2, **hints): "Allow any relation if a model in Auth is involved" - return obj1._meta.app_label == 'auth' or obj2._meta.app_label == 'auth' or None + return obj1._meta.app_label == "auth" or obj2._meta.app_label == "auth" or None def allow_migrate(self, db, app_label, **hints): "Make sure the auth app only appears on the 'other' db" - if app_label == 'auth': - return db == 'other' + if app_label == "auth": + return db == "other" return None class WriteRouter: # A router that only expresses an opinion on writes def db_for_write(self, model, **hints): - return 'writer' + return "writer" |
