MCPcopy
hub / github.com/django/django / test_validate_fk_attname

Method test_validate_fk_attname

tests/constraints/tests.py:364–378  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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(
366 condition=models.Q(uniqueconstraintproduct_ptr_id__isnull=False),
367 name="parent_ptr_present",
368 )
369 with self.assertRaisesMessage(
370 ValidationError, "Constraint “parent_ptr_present” is violated."
371 ):
372 constraint_with_fk.validate(
373 ChildUniqueConstraintProduct, ChildUniqueConstraintProduct()
374 )
375 constraint_with_fk.validate(
376 ChildUniqueConstraintProduct,
377 ChildUniqueConstraintProduct(uniqueconstraintproduct_ptr_id=1),
378 )
379
380 @skipUnlessDBFeature("supports_json_field")
381 def test_validate_jsonfield_exact(self):

Callers

nothing calls this directly

Calls 3

validateMethod · 0.95
assertRaisesMessageMethod · 0.80

Tested by

no test coverage detected