summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTillmann Karras <tilkax@gmail.com>2014-11-16 18:42:23 +0100
committerTim Graham <timograham@gmail.com>2014-11-18 09:20:04 +0100
commitdfcac7d7f5f1f108ae2c561f0f755f08d75a1c27 (patch)
tree220c26fe16960e032ac0b3fa21f5834b7dd4007c /tests
parent229abe62fa9c269cd8dda19ba62b25714ce0ee15 (diff)
[1.7.x] Fixed #23799 -- Made makemigrations respect --no-optimize.
Thanks to yamila-moreno for the idea of a skip message. Backport of d18810131995dac63f9d89b0beaeadfc935130aa from master
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_commands.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index 00b7f65ab8..a889ec8037 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -546,3 +546,45 @@ class MakeMigrationsTests(MigrationTestBase):
questioner.input = old_input
if os.path.exists(merge_file):
os.remove(merge_file)
+
+
+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_system_checks([])
+ @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_system_checks([])
+ @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_system_checks([])
+ @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())