summaryrefslogtreecommitdiff
path: root/tests/constraints
diff options
context:
space:
mode:
Diffstat (limited to 'tests/constraints')
-rw-r--r--tests/constraints/tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py
index 4032b418b4..d4054dfd77 100644
--- a/tests/constraints/tests.py
+++ b/tests/constraints/tests.py
@@ -685,6 +685,20 @@ class UniqueConstraintTests(TestCase):
exclude={"color"},
)
+ def test_validate_expression_str(self):
+ constraint = models.UniqueConstraint("name", name="name_uniq")
+ msg = "Constraint “name_uniq” is violated."
+ with self.assertRaisesMessage(ValidationError, msg):
+ constraint.validate(
+ UniqueConstraintProduct,
+ UniqueConstraintProduct(name=self.p1.name),
+ )
+ constraint.validate(
+ UniqueConstraintProduct,
+ UniqueConstraintProduct(name=self.p1.name),
+ exclude={"name"},
+ )
+
def test_name(self):
constraints = get_constraints(UniqueConstraintProduct._meta.db_table)
expected_name = "name_color_uniq"