diff options
| author | Kirill Safronov <hoskeowl@gmail.com> | 2022-02-01 00:29:49 +0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-01 07:01:41 +0100 |
| commit | 97a72744681d0993b50dee952cf32cdf9650ad9f (patch) | |
| tree | dd5033ada06acf3e80c80897d24e012ece62c3e7 /tests | |
| parent | 71e7c8e73712419626f1c2b6ec036e8559a2d667 (diff) | |
Fixed #33480 -- Fixed makemigrations crash when renaming field of renamed model.
Regression in aa4acc164d1247c0de515c959f7b09648b57dc42.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_autodetector.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index bb37af24e3..dddd4e0c94 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -1049,6 +1049,26 @@ class AutodetectorTests(TestCase): new_name='renamed_foo', ) + def test_rename_field_with_renamed_model(self): + changes = self.get_changes( + [self.author_name], + [ + ModelState('testapp', 'RenamedAuthor', [ + ('id', models.AutoField(primary_key=True)), + ('renamed_name', models.CharField(max_length=200)), + ]), + ], + MigrationQuestioner({'ask_rename_model': True, 'ask_rename': True}), + ) + self.assertNumberMigrations(changes, 'testapp', 1) + self.assertOperationTypes(changes, 'testapp', 0, ['RenameModel', 'RenameField']) + self.assertOperationAttributes( + changes, 'testapp', 0, 0, old_name='Author', new_name='RenamedAuthor', + ) + self.assertOperationAttributes( + changes, 'testapp', 0, 1, old_name='name', new_name='renamed_name', + ) + def test_rename_model(self): """Tests autodetection of renamed models.""" changes = self.get_changes( |
