summaryrefslogtreecommitdiff
path: root/tests/migrations/routers.py
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2019-12-20 20:49:56 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-01-20 14:39:02 +0100
commit2a2ea4ee18fdcf2c95bf6435bc63b74623e3085b (patch)
tree32c7c87c71535a8493c07e2073f1bfcd1aa7e24d /tests/migrations/routers.py
parent26be703fe679a58bbdccf37a276a9c430ccb29f7 (diff)
downloaddjango-2a2ea4ee18fdcf2c95bf6435bc63b74623e3085b.tar.gz
Refs #31117 -- Made various tests properly handle unexpected databases aliases.
- Used selected "databases" instead of django.db.connections. - Made routers in tests.migrations skip migrations on unexpected databases. - Added DiscoverRunnerGetDatabasesTests.assertSkippedDatabases() hook which properly asserts messages about skipped databases.
Diffstat (limited to 'tests/migrations/routers.py')
-rw-r--r--tests/migrations/routers.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/migrations/routers.py b/tests/migrations/routers.py
index 21dfc561bd..bc036382a7 100644
--- a/tests/migrations/routers.py
+++ b/tests/migrations/routers.py
@@ -1,5 +1,6 @@
-class EmptyRouter:
- pass
+class DefaultOtherRouter:
+ def allow_migrate(self, db, app_label, model_name=None, **hints):
+ return db in {'default', 'other'}
class TestRouter:
@@ -9,5 +10,5 @@ class TestRouter:
"""
if model_name == 'tribble':
return db == 'other'
- elif db == 'other':
+ elif db != 'default':
return False