diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2014-12-11 17:52:42 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-12-11 13:28:57 -0500 |
| commit | f446acf8bbd6360fdb5a9d34186c5fadf98282b7 (patch) | |
| tree | e99f6e01c5e203f7ff795e044363652fbe5eb50f /tests | |
| parent | 491bf20d190b88ec64b9e9c6579d0bd165925677 (diff) | |
[1.7.x] Fixed #23956 -- Fixed migration creation for multiple table inheritance
Backport of 44927ba817a4ecf9834d429ff6c86bc5ac961305 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_autodetector.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index 9adbf21e4d..5d1749f4a3 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -1405,6 +1405,29 @@ class AutodetectorTests(TestCase): self.assertOperationAttributes(changes, 'testapp', 0, 0, name="Author") self.assertOperationAttributes(changes, 'testapp', 0, 1, name="Aardvark") + def test_multiple_bases(self): + """#23956 - Tests that inheriting models doesn't move *_ptr fields into AddField operations.""" + A = ModelState("app", "A", [("a_id", models.AutoField(primary_key=True))]) + B = ModelState("app", "B", [("b_id", models.AutoField(primary_key=True))]) + C = ModelState("app", "C", [], bases=("app.A", "app.B")) + D = ModelState("app", "D", [], bases=("app.A", "app.B")) + E = ModelState("app", "E", [], bases=("app.A", "app.B")) + # Make state + before = self.make_project_state([]) + after = self.make_project_state([A, B, C, D, E]) + autodetector = MigrationAutodetector(before, after) + changes = autodetector._detect_changes() + # Right number/type of migrations? + self.assertNumberMigrations(changes, "app", 1) + self.assertOperationTypes(changes, "app", 0, [ + "CreateModel", "CreateModel", "CreateModel", "CreateModel", "CreateModel" + ]) + self.assertOperationAttributes(changes, "app", 0, 0, name="A") + self.assertOperationAttributes(changes, "app", 0, 1, name="B") + self.assertOperationAttributes(changes, "app", 0, 2, name="C") + self.assertOperationAttributes(changes, "app", 0, 3, name="D") + self.assertOperationAttributes(changes, "app", 0, 4, name="E") + def test_proxy_bases_first(self): """Tests that bases of proxies come first.""" # Make state |
