summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-26 23:18:59 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-26 23:20:21 +0200
commit5263480d7f04ffdb845c37770680d605f1306f7c (patch)
treea56777ed29f4b13c2daf607bca01b471bd4624b9 /tests
parent1a3029b6b4faf400232c38ff70fb74a97b14d1a9 (diff)
[3.1.x] Fixed #31742 -- Fixed makemigrations crash on ForeignKey to an app with mixed case label.
Regression in 9e1b6b8a66af4c2197e5b1b41eb9dbb36e4f6502. Thanks Ignacio Santolin for the report. Backport of 62d85a283500e9abb0e1c9ec53c59be468f056a0 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_state.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index 40277bf506..5ac9bf858f 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -867,6 +867,34 @@ class StateTests(SimpleTestCase):
with self.assertRaisesMessage(ValueError, msg):
project_state.apps
+ def test_reference_mixed_case_app_label(self):
+ new_apps = Apps()
+
+ class Author(models.Model):
+ class Meta:
+ app_label = 'MiXedCase_migrations'
+ apps = new_apps
+
+ class Book(models.Model):
+ author = models.ForeignKey(Author, models.CASCADE)
+
+ class Meta:
+ app_label = 'MiXedCase_migrations'
+ apps = new_apps
+
+ class Magazine(models.Model):
+ authors = models.ManyToManyField(Author)
+
+ class Meta:
+ app_label = 'MiXedCase_migrations'
+ apps = new_apps
+
+ project_state = ProjectState()
+ project_state.add_model(ModelState.from_model(Author))
+ project_state.add_model(ModelState.from_model(Book))
+ project_state.add_model(ModelState.from_model(Magazine))
+ self.assertEqual(len(project_state.apps.get_models()), 3)
+
def test_real_apps(self):
"""
Including real apps can resolve dangling FK errors.