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:07:27 -0700 |
| commit | 13aa079941dcfd953ba03a83f55c8a14399d15c2 (patch) | |
| tree | 6dcc4702a0667b6930bc1465453977d4c3ded4c2 /tests | |
| parent | a067c61b94926f408e151ff5b4e0ce0d3b775183 (diff) | |
[1.7.x] 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 f969ae50ac..48c76d1bca 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -738,6 +738,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 |
