summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKirill Safronov <hoskeowl@gmail.com>2022-02-01 00:29:49 +0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-01 07:33:22 +0100
commit6928227dffe45f06deed9a218a188e6ed11334ba (patch)
treed7ec103d4d18277d69345f4208c89f8f5b9b998f /tests
parentaff79be03a8c787ba0cc7e00dcec9eeb8ad01c87 (diff)
[4.0.x] Fixed #33480 -- Fixed makemigrations crash when renaming field of renamed model.
Regression in aa4acc164d1247c0de515c959f7b09648b57dc42. Backport of 97a72744681d0993b50dee952cf32cdf9650ad9f from main
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_autodetector.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
index e0cf9d49ef..766d21fb3b 100644
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -1043,6 +1043,26 @@ class AutodetectorTests(TestCase):
{'to': 'app.foo', 'on_delete': models.CASCADE, 'db_column': 'foo_id'},
))
+ 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(