diff options
| author | Tillmann Karras <tilkax@gmail.com> | 2014-11-16 18:42:23 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-11-18 07:37:06 +0100 |
| commit | d18810131995dac63f9d89b0beaeadfc935130aa (patch) | |
| tree | 7c6215c8e7f41b366310de9b54a4cdb0646be304 /tests | |
| parent | dee3946a91be2c880b5930550db681aae54b19ed (diff) | |
Fixed #23799 -- Made makemigrations respect --no-optimize.
Thanks to yamila-moreno for the idea of a skip message.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_commands.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index f4e3878d17..83826e819d 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -543,3 +543,42 @@ class MakeMigrationsTests(MigrationTestBase): content = cmd("0002", migration_name_0002, "--empty") self.assertIn("dependencies=[\n('migrations','0001_%s'),\n]" % migration_name_0001, content) self.assertIn("operations=[\n]", content) + + +class SquashMigrationsTest(MigrationTestBase): + """ + Tests running the squashmigrations command. + """ + + path = "migrations/test_migrations/0001_squashed_0002_second.py" + + def tearDown(self): + if os.path.exists(self.path): + os.remove(self.path) + + @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) + def test_squashmigrations_squashes(self): + """ + Tests that squashmigrations squashes migrations. + """ + call_command("squashmigrations", "migrations", "0002", interactive=False, verbosity=0) + self.assertTrue(os.path.exists(self.path)) + + @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) + def test_squashmigrations_optimizes(self): + """ + Tests that squashmigrations optimizes operations. + """ + out = six.StringIO() + call_command("squashmigrations", "migrations", "0002", interactive=False, verbosity=1, stdout=out) + self.assertIn("Optimized from 7 operations to 5 operations.", out.getvalue()) + + @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) + def test_ticket_23799_squashmigrations_no_optimize(self): + """ + Makes sure that squashmigrations --no-optimize really doesn't optimize operations. + """ + out = six.StringIO() + call_command("squashmigrations", "migrations", "0002", + interactive=False, verbosity=1, no_optimize=True, stdout=out) + self.assertIn("Skipping optimization", out.getvalue()) |
