summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_constraints.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/postgres_tests/test_constraints.py')
-rw-r--r--tests/postgres_tests/test_constraints.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py
index b3de53efd7..3cc76cdcfe 100644
--- a/tests/postgres_tests/test_constraints.py
+++ b/tests/postgres_tests/test_constraints.py
@@ -266,6 +266,19 @@ class SchemaTests(PostgreSQLTestCase):
self.assertNotIn(constraint.name, self.get_constraints(Scene._meta.db_table))
Scene.objects.create(scene="ScEnE 10", setting="Sir Bedemir's Castle")
+ def test_opclass_func_validate_constraints(self):
+ constraint_name = "test_opclass_func_validate_constraints"
+ constraint = UniqueConstraint(
+ OpClass(Lower("scene"), name="text_pattern_ops"),
+ name="test_opclass_func_validate_constraints",
+ )
+ Scene.objects.create(scene="First scene")
+ # Non-unique scene.
+ msg = f"Constraint “{constraint_name}” is violated."
+ with self.assertRaisesMessage(ValidationError, msg):
+ constraint.validate(Scene, Scene(scene="first Scene"))
+ constraint.validate(Scene, Scene(scene="second Scene"))
+
class ExclusionConstraintTests(PostgreSQLTestCase):
def get_constraints(self, table):