diff options
| author | Josep Cugat <jcugat@gmail.com> | 2015-11-06 12:36:38 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-11-09 10:50:02 -0500 |
| commit | a42c5376e764712d8ff4a1f9dd3c2d5537722288 (patch) | |
| tree | be40d0f39a84bbe6f67a66f945b6b2d32504f89d /tests/multiple_database | |
| parent | 94d13415d81f24743045bcaa43027c737e2bcf5f (diff) | |
[1.8.x] Fixed #25686 -- Fixed crash on routers without an allow_migrate() method.
Thanks Simon Charette for review.
Diffstat (limited to 'tests/multiple_database')
| -rw-r--r-- | tests/multiple_database/tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py index cad410baff..d329340eec 100644 --- a/tests/multiple_database/tests.py +++ b/tests/multiple_database/tests.py @@ -956,6 +956,27 @@ class RouterTestCase(TestCase): self.assertTrue(router.allow_migrate('default', 'app_label')) self.assertEqual(force_text(recorded.pop().message), msg) + def test_allow_syncdb_deprecation(self): + class LegacyRouter(object): + def allow_syncdb(self, db, model): + assert db == 'default' + assert model is User + return True + + with override_settings(DATABASE_ROUTERS=[LegacyRouter()]): + with warnings.catch_warnings(record=True) as recorded: + warnings.filterwarnings('always') + msg = ( + "Router.allow_syncdb has been deprecated and will stop " + "working in Django 1.9. Rename the method to allow_migrate." + ) + self.assertTrue(router.allow_migrate_model('default', User)) + self.assertEqual(force_text(recorded.pop().message), msg) + self.assertEqual(recorded, []) + + self.assertTrue(router.allow_migrate('default', 'app_label')) + self.assertEqual(force_text(recorded.pop().message), msg) + def test_partial_router(self): "A router can choose to implement a subset of methods" dive = Book.objects.using('other').create(title="Dive into Python", |
