summaryrefslogtreecommitdiff
path: root/tests/migrations
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2020-01-13 16:17:52 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-03-25 10:39:34 +0100
commit9e1b6b8a66af4c2197e5b1b41eb9dbb36e4f6502 (patch)
treebb84b9aa85757a92540585fe8bcf9e399d7676c0 /tests/migrations
parentf3da09df0f4147223ab76a00a841586ccf11005d (diff)
Fixed #23916 -- Allowed makemigrations to handle related model name case changes.
Made autodetector ignore related model name case changes so unnecessary migrations are not created.
Diffstat (limited to 'tests/migrations')
-rw-r--r--tests/migrations/test_autodetector.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
index 633d40a26f..daff57fc2c 100644
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -1014,7 +1014,7 @@ class AutodetectorTests(TestCase):
'renamed_foo',
'django.db.models.ForeignKey',
[],
- {'to': 'app.Foo', 'on_delete': models.CASCADE, 'db_column': 'foo_id'},
+ {'to': 'app.foo', 'on_delete': models.CASCADE, 'db_column': 'foo_id'},
))
def test_rename_model(self):
@@ -1032,6 +1032,22 @@ class AutodetectorTests(TestCase):
# no AlterField for the related field.
self.assertNumberMigrations(changes, 'otherapp', 0)
+ def test_rename_model_case(self):
+ """
+ Model name is case-insensitive. Changing case doesn't lead to any
+ autodetected operations.
+ """
+ author_renamed = ModelState('testapp', 'author', [
+ ('id', models.AutoField(primary_key=True)),
+ ])
+ changes = self.get_changes(
+ [self.author_empty, self.book],
+ [author_renamed, self.book],
+ questioner=MigrationQuestioner({'ask_rename_model': True}),
+ )
+ self.assertNumberMigrations(changes, 'testapp', 0)
+ self.assertNumberMigrations(changes, 'otherapp', 0)
+
def test_rename_m2m_through_model(self):
"""
Tests autodetection of renamed models that are used in M2M relations as