mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #27461 -- Fixed incorrect allow_migrate() arguments in makemigrations.
This commit is contained in:
parent
0d6c7cae7c
commit
373c6c409c
3 changed files with 15 additions and 2 deletions
|
@ -598,6 +598,7 @@ class MakeMigrationsTests(MigrationTestBase):
|
|||
init_file = os.path.join(migration_dir, '__init__.py')
|
||||
self.assertTrue(os.path.exists(init_file))
|
||||
|
||||
@override_settings(INSTALLED_APPS=['migrations', 'migrations2'])
|
||||
def test_makemigrations_consistency_checks_respect_routers(self):
|
||||
"""
|
||||
The history consistency checks in makemigrations respect
|
||||
|
@ -638,7 +639,15 @@ class MakeMigrationsTests(MigrationTestBase):
|
|||
with self.settings(DATABASE_ROUTERS=['migrations.routers.TestRouter']):
|
||||
with mock.patch.object(TestRouter, 'allow_migrate', return_value=False) as allow_migrate:
|
||||
call_command('makemigrations', 'migrations', verbosity=0)
|
||||
allow_migrate.assert_called_with('other', 'migrations', model_name='UnicodeModel')
|
||||
allow_migrate.assert_any_call('other', 'migrations', model_name='UnicodeModel')
|
||||
# allow_migrate() is called with the correct arguments.
|
||||
self.assertGreater(len(allow_migrate.mock_calls), 0)
|
||||
for mock_call in allow_migrate.mock_calls:
|
||||
_, call_args, call_kwargs = mock_call
|
||||
connection_alias, app_name = call_args
|
||||
self.assertIn(connection_alias, ['default', 'other'])
|
||||
# Raises an error if invalid app_name/model_name occurs.
|
||||
apps.get_app_config(app_name).get_model(call_kwargs['model_name'])
|
||||
self.assertEqual(ensure_schema.call_count, 4)
|
||||
|
||||
def test_failing_migration(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue