diff options
| author | David Wobrock <david.wobrock@gmail.com> | 2020-03-08 22:44:34 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-03-09 08:21:34 +0100 |
| commit | b88ad1d356844da10035af6e09603afdaf84a169 (patch) | |
| tree | 883bd98111df67ed74e14e6d77e4f9276e3e1673 | |
| parent | 370628673b98ada302c3930865c4bfde2d8ed5a1 (diff) | |
Refs #31318 -- Added tests for inspecting squashed migrations and ambiguous names in sqlmigrate.
| -rw-r--r-- | tests/migrations/test_commands.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index b98b77cd99..7fd1a68422 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -695,6 +695,24 @@ class MigrateTests(MigrationTestBase): self.assertNotIn(start_transaction_sql.lower(), queries) self.assertNotIn(connection.ops.end_transaction_sql().lower(), queries) + @override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_squashed'}) + def test_sqlmigrate_ambiguous_prefix_squashed_migrations(self): + msg = ( + "More than one migration matches '0001' in app 'migrations'. " + "Please be more specific." + ) + with self.assertRaisesMessage(CommandError, msg): + call_command('sqlmigrate', 'migrations', '0001') + + @override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_squashed'}) + def test_sqlmigrate_squashed_migration(self): + out = io.StringIO() + call_command('sqlmigrate', 'migrations', '0001_squashed_0002', stdout=out) + output = out.getvalue().lower() + self.assertIn('-- create model author', output) + self.assertIn('-- create model book', output) + self.assertNotIn('-- create model tribble', output) + @override_settings(MIGRATION_MODULES={'migrations': 'migrations.test_migrations_no_operations'}) def test_migrations_no_operations(self): err = io.StringIO() |
