diff options
| author | Joseph Kahn <josephbkahn@gmail.com> | 2016-11-09 10:27:19 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-11-09 10:27:33 -0500 |
| commit | 7fd379719a1f5ee059aeee88243af172719e5e35 (patch) | |
| tree | b48d77a48dc180dbf8ae9168c48c7d5be6c56a74 /tests | |
| parent | 3dc480fcd2c086a124647a611ac7647e75506e14 (diff) | |
[1.10.x] Fixed #27461 -- Fixed incorrect allow_migrate() arguments in makemigrations.
Backport of 373c6c409c310cb61e1e9c9aff4adba379ffd0b4 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_commands.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index da10f834f0..63f29dba6a 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -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): |
