(self)
| 349 | is_not_null_constraint.validate(JSONFieldModel, JSONFieldModel(data={})) |
| 350 | |
| 351 | def test_validate_pk_field(self): |
| 352 | constraint_with_pk = models.CheckConstraint( |
| 353 | condition=~models.Q(pk=models.F("age")), |
| 354 | name="pk_not_age_check", |
| 355 | ) |
| 356 | constraint_with_pk.validate(ChildModel, ChildModel(pk=1, age=2)) |
| 357 | msg = f"Constraint “{constraint_with_pk.name}” is violated." |
| 358 | with self.assertRaisesMessage(ValidationError, msg): |
| 359 | constraint_with_pk.validate(ChildModel, ChildModel(pk=1, age=1)) |
| 360 | with self.assertRaisesMessage(ValidationError, msg): |
| 361 | constraint_with_pk.validate(ChildModel, ChildModel(id=1, age=1)) |
| 362 | constraint_with_pk.validate(ChildModel, ChildModel(pk=1, age=1), exclude={"pk"}) |
| 363 | |
| 364 | def test_validate_fk_attname(self): |
| 365 | constraint_with_fk = models.CheckConstraint( |
nothing calls this directly
no test coverage detected