summaryrefslogtreecommitdiff
path: root/tests/migrations/test_state.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/migrations/test_state.py')
-rw-r--r--tests/migrations/test_state.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index dbbdf77734..d6ecaa1c5d 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -1206,6 +1206,28 @@ class StateTests(SimpleTestCase):
choices_field = Author._meta.get_field("choice")
self.assertEqual(list(choices_field.choices), choices)
+ def test_composite_pk_state(self):
+ new_apps = Apps(["migrations"])
+
+ class Foo(models.Model):
+ pk = models.CompositePrimaryKey("account_id", "id")
+ account_id = models.SmallIntegerField()
+ id = models.SmallIntegerField()
+
+ class Meta:
+ app_label = "migrations"
+ apps = new_apps
+
+ project_state = ProjectState.from_apps(new_apps)
+ model_state = project_state.models["migrations", "foo"]
+ self.assertEqual(len(model_state.options), 2)
+ self.assertEqual(model_state.options["constraints"], [])
+ self.assertEqual(model_state.options["indexes"], [])
+ self.assertEqual(len(model_state.fields), 3)
+ self.assertIn("pk", model_state.fields)
+ self.assertIn("account_id", model_state.fields)
+ self.assertIn("id", model_state.fields)
+
class StateRelationsTests(SimpleTestCase):
def get_base_project_state(self):