summaryrefslogtreecommitdiff
path: root/tests/constraints
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-05-05 06:44:34 +0200
committerGitHub <noreply@github.com>2022-05-05 06:44:34 +0200
commit27b07a3246bc033cd9ded01238c6dc64731cce35 (patch)
treee07edb39cde77b8b335182b1604f5e51f294e606 /tests/constraints
parentc5cc750b56e0ed396ca36be39e39505ed6ede4b1 (diff)
downloaddjango-27b07a3246bc033cd9ded01238c6dc64731cce35.tar.gz
Refs #30581 -- Moved CheckConstraint tests for conditional expressions to migrations.test_operations.
This allows avoiding warning in tests about using RawSQL in CheckConstraints.
Diffstat (limited to 'tests/constraints')
-rw-r--r--tests/constraints/models.py13
-rw-r--r--tests/constraints/tests.py14
2 files changed, 0 insertions, 27 deletions
diff --git a/tests/constraints/models.py b/tests/constraints/models.py
index c4450383e7..245693e847 100644
--- a/tests/constraints/models.py
+++ b/tests/constraints/models.py
@@ -20,19 +20,6 @@ class Product(models.Model):
name="%(app_label)s_%(class)s_price_gt_0",
),
models.CheckConstraint(
- check=models.expressions.RawSQL(
- "price < %s", (1000,), output_field=models.BooleanField()
- ),
- name="%(app_label)s_price_lt_1000_raw",
- ),
- models.CheckConstraint(
- check=models.expressions.ExpressionWrapper(
- models.Q(price__gt=500) | models.Q(price__lt=500),
- output_field=models.BooleanField(),
- ),
- name="%(app_label)s_price_neq_500_wrap",
- ),
- models.CheckConstraint(
check=models.Q(
models.Q(unit__isnull=True) | models.Q(unit__in=["μg/mL", "ng/mL"])
),
diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py
index 722483128b..58960fa5a3 100644
--- a/tests/constraints/tests.py
+++ b/tests/constraints/tests.py
@@ -103,18 +103,6 @@ class CheckConstraintTests(TestCase):
with self.assertRaises(IntegrityError):
Product.objects.create(price=10, discounted_price=7, unit="l")
- @skipUnlessDBFeature("supports_table_check_constraints")
- def test_database_constraint_expression(self):
- Product.objects.create(price=999, discounted_price=5)
- with self.assertRaises(IntegrityError):
- Product.objects.create(price=1000, discounted_price=5)
-
- @skipUnlessDBFeature("supports_table_check_constraints")
- def test_database_constraint_expressionwrapper(self):
- Product.objects.create(price=499, discounted_price=5)
- with self.assertRaises(IntegrityError):
- Product.objects.create(price=500, discounted_price=5)
-
@skipUnlessDBFeature(
"supports_table_check_constraints", "can_introspect_check_constraints"
)
@@ -122,8 +110,6 @@ class CheckConstraintTests(TestCase):
constraints = get_constraints(Product._meta.db_table)
for expected_name in (
"price_gt_discounted_price",
- "constraints_price_lt_1000_raw",
- "constraints_price_neq_500_wrap",
"constraints_product_price_gt_0",
):
with self.subTest(expected_name):