(self)
| 1065 | ) |
| 1066 | |
| 1067 | def test_validate_case_when(self): |
| 1068 | UniqueConstraintProduct.objects.create(name="p1") |
| 1069 | constraint = models.UniqueConstraint( |
| 1070 | Case(When(color__isnull=True, then=F("name"))), |
| 1071 | name="name_without_color_uniq", |
| 1072 | ) |
| 1073 | msg = "Constraint “name_without_color_uniq” is violated." |
| 1074 | with self.assertRaisesMessage(ValidationError, msg): |
| 1075 | constraint.validate( |
| 1076 | UniqueConstraintProduct, |
| 1077 | UniqueConstraintProduct(name="p1"), |
| 1078 | ) |
| 1079 | constraint.validate( |
| 1080 | UniqueConstraintProduct, |
| 1081 | UniqueConstraintProduct(name="p1", color="green"), |
| 1082 | ) |
| 1083 | |
| 1084 | def test_validate_ordered_expression(self): |
| 1085 | constraint = models.UniqueConstraint( |
nothing calls this directly
no test coverage detected