diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2021-06-06 14:45:36 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-08-30 11:40:27 +0200 |
| commit | 9e17cc062c62eec1177aaf65ebebba43e074cde2 (patch) | |
| tree | d4e73d7ef2e6d50a78cae5ccd810fad0499889a8 /tests | |
| parent | cbba49971bbbbe3e8c6685e4ce6ab87b1187ae87 (diff) | |
Refs #24900 -- Added MigrationLoader test for applying squashed migrations.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_loader.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py index 3c4f44aa5e..03a98506e3 100644 --- a/tests/migrations/test_loader.py +++ b/tests/migrations/test_loader.py @@ -485,6 +485,27 @@ class LoaderTests(TestCase): } self.assertEqual(plan, expected_plan) + # Load with nothing applied and migrate to a replaced migration. + # Not possible if loader.replace_migrations is True (default). + loader.build_graph() + msg = "Node ('app1', '3_auto') not a valid node" + with self.assertRaisesMessage(NodeNotFoundError, msg): + loader.graph.forwards_plan(('app1', '3_auto')) + # Possible if loader.replace_migrations is False. + loader.replace_migrations = False + loader.build_graph() + plan = set(loader.graph.forwards_plan(('app1', '3_auto'))) + plan = plan - loader.applied_migrations.keys() + expected_plan = { + ('app1', '1_auto'), + ('app2', '1_auto'), + ('app2', '2_auto'), + ('app1', '2_auto'), + ('app1', '3_auto'), + } + self.assertEqual(plan, expected_plan) + loader.replace_migrations = True + # Fake-apply a few from app1: unsquashes migration in app1. self.record_applied(recorder, 'app1', '1_auto') self.record_applied(recorder, 'app1', '2_auto') |
