Makes sure ProjectState doesn't include OrderWrt fields when making from existing models.
(self)
| 1064 | ProjectState(real_apps=["contenttypes"]) |
| 1065 | |
| 1066 | def test_ignore_order_wrt(self): |
| 1067 | """ |
| 1068 | Makes sure ProjectState doesn't include OrderWrt fields when |
| 1069 | making from existing models. |
| 1070 | """ |
| 1071 | new_apps = Apps() |
| 1072 | |
| 1073 | class Author(models.Model): |
| 1074 | name = models.TextField() |
| 1075 | |
| 1076 | class Meta: |
| 1077 | app_label = "migrations" |
| 1078 | apps = new_apps |
| 1079 | |
| 1080 | class Book(models.Model): |
| 1081 | author = models.ForeignKey(Author, models.CASCADE) |
| 1082 | |
| 1083 | class Meta: |
| 1084 | app_label = "migrations" |
| 1085 | apps = new_apps |
| 1086 | order_with_respect_to = "author" |
| 1087 | |
| 1088 | # Make a valid ProjectState and render it |
| 1089 | project_state = ProjectState() |
| 1090 | project_state.add_model(ModelState.from_model(Author)) |
| 1091 | project_state.add_model(ModelState.from_model(Book)) |
| 1092 | self.assertEqual( |
| 1093 | list(project_state.models["migrations", "book"].fields), |
| 1094 | ["id", "author"], |
| 1095 | ) |
| 1096 | |
| 1097 | def test_modelstate_get_field_order_wrt(self): |
| 1098 | new_apps = Apps() |
nothing calls this directly
no test coverage detected