diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-06-15 12:06:48 -0700 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-06-15 12:06:48 -0700 |
| commit | f717ef083aac2e839a86de1bac02b95e5fd1a4b1 (patch) | |
| tree | 35d35392b751b5efbcde943508ee2cae3eaf5ecf /tests | |
| parent | 24afb1d7a746da131212d050404bbe8837cf6f1d (diff) | |
Fixed #22833: Autodetector not doing through mapping correctly
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_autodetector.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index d6a908143d..758aa8915e 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -750,6 +750,21 @@ class AutodetectorTests(TestCase): self.assertEqual(action.__class__.__name__, "DeleteModel") self.assertEqual(action.name, "Attribution") + def test_many_to_many_removed_before_through_model_2(self): + """ + Removing a model that contains a ManyToManyField and the + "through" model in the same change must remove + the field before the model to maintain consistency. + """ + before = self.make_project_state([self.book_with_multiple_authors_through_attribution, self.author_name, self.attribution]) + after = self.make_project_state([self.author_name]) # removes both the through model and ManyToMany + autodetector = MigrationAutodetector(before, after) + changes = autodetector._detect_changes() + # Right number of migrations? + self.assertNumberMigrations(changes, 'otherapp', 1) + # Right number of actions? + self.assertOperationTypes(changes, 'otherapp', 0, ["RemoveField", "RemoveField", "RemoveField", "DeleteModel", "DeleteModel"]) + def test_m2m_w_through_multistep_remove(self): """ A model with a m2m field that specifies a "through" model cannot be removed in the same |
