diff options
| author | Adam Johnson <me@adamj.eu> | 2022-02-10 20:16:33 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-04-21 12:25:16 +0200 |
| commit | 6f453cd2981525b33925faaadc7a6e51fa90df5c (patch) | |
| tree | 068644a4703bc05207402c3582a4c370e7b6353d /tests/migrations/test_commands.py | |
| parent | f15f7d395c99e3c1194c37eaa4f5958392c1ee07 (diff) | |
Fixed #33509 -- Added "(no-op)" to sqlmigrate output for operations without SQL statement.
Diffstat (limited to 'tests/migrations/test_commands.py')
| -rw-r--r-- | tests/migrations/test_commands.py | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index 7ea8267247..a3e1efc924 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -1021,12 +1021,52 @@ class MigrateTests(MigrationTestBase): @override_settings( MIGRATION_MODULES={"migrations": "migrations.test_migrations_no_operations"} ) - def test_migrations_no_operations(self): + def test_sqlmigrate_no_operations(self): err = io.StringIO() call_command("sqlmigrate", "migrations", "0001_initial", stderr=err) self.assertEqual(err.getvalue(), "No operations found.\n") @override_settings( + MIGRATION_MODULES={"migrations": "migrations.test_migrations_noop"} + ) + def test_sqlmigrate_noop(self): + out = io.StringIO() + call_command("sqlmigrate", "migrations", "0001", stdout=out) + lines = out.getvalue().splitlines() + + if connection.features.can_rollback_ddl: + lines = lines[1:-1] + self.assertEqual( + lines, + [ + "--", + "-- Raw SQL operation", + "--", + "-- (no-op)", + ], + ) + + @override_settings( + MIGRATION_MODULES={"migrations": "migrations.test_migrations_manual_porting"} + ) + def test_sqlmigrate_unrepresentable(self): + out = io.StringIO() + call_command("sqlmigrate", "migrations", "0002", stdout=out) + lines = out.getvalue().splitlines() + + if connection.features.can_rollback_ddl: + lines = lines[1:-1] + self.assertEqual( + lines, + [ + "--", + "-- Raw Python operation", + "--", + "-- THIS OPERATION CANNOT BE WRITTEN AS SQL", + ], + ) + + @override_settings( INSTALLED_APPS=[ "migrations.migrations_test_apps.migrated_app", "migrations.migrations_test_apps.migrated_unapplied_app", |
