diff options
| author | Simon Charette <charette.s@gmail.com> | 2024-02-26 00:14:26 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-03-01 07:15:32 +0100 |
| commit | daf7d482dbaaa2604241a994c49f442fa15142c1 (patch) | |
| tree | 65eae557dbe8694e03130cc17259a792792c95b7 /tests/postgres_tests | |
| parent | f82c67aa217c8dd4320ef697b04a6da1681aa799 (diff) | |
Refs #35234 -- Deprecated CheckConstraint.check in favor of .condition.
Once the deprecation period ends CheckConstraint.check() can become the
documented method that performs system checks for BaseConstraint
subclasses.
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/test_constraints.py | 18 | ||||
| -rw-r--r-- | tests/postgres_tests/test_operations.py | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py index ee0be3cbb3..b3de53efd7 100644 --- a/tests/postgres_tests/test_constraints.py +++ b/tests/postgres_tests/test_constraints.py @@ -59,7 +59,7 @@ class SchemaTests(PostgreSQLTestCase): constraint_name, self.get_constraints(RangesModel._meta.db_table) ) constraint = CheckConstraint( - check=Q(ints__contained_by=NumericRange(10, 30)), + condition=Q(ints__contained_by=NumericRange(10, 30)), name=constraint_name, ) with connection.schema_editor() as editor: @@ -71,7 +71,7 @@ class SchemaTests(PostgreSQLTestCase): def test_check_constraint_array_contains(self): constraint = CheckConstraint( - check=Q(field__contains=[1]), + condition=Q(field__contains=[1]), name="array_contains", ) msg = f"Constraint “{constraint.name}” is violated." @@ -81,7 +81,7 @@ class SchemaTests(PostgreSQLTestCase): def test_check_constraint_array_length(self): constraint = CheckConstraint( - check=Q(field__len=1), + condition=Q(field__len=1), name="array_length", ) msg = f"Constraint “{constraint.name}” is violated." @@ -95,7 +95,7 @@ class SchemaTests(PostgreSQLTestCase): constraint_name, self.get_constraints(RangesModel._meta.db_table) ) constraint = CheckConstraint( - check=Q(dates__contains=F("dates_inner")), + condition=Q(dates__contains=F("dates_inner")), name=constraint_name, ) with connection.schema_editor() as editor: @@ -119,7 +119,7 @@ class SchemaTests(PostgreSQLTestCase): constraint_name, self.get_constraints(RangesModel._meta.db_table) ) constraint = CheckConstraint( - check=Q(timestamps__contains=F("timestamps_inner")), + condition=Q(timestamps__contains=F("timestamps_inner")), name=constraint_name, ) with connection.schema_editor() as editor: @@ -139,7 +139,7 @@ class SchemaTests(PostgreSQLTestCase): def test_check_constraint_range_contains(self): constraint = CheckConstraint( - check=Q(ints__contains=(1, 5)), + condition=Q(ints__contains=(1, 5)), name="ints_contains", ) msg = f"Constraint “{constraint.name}” is violated." @@ -148,7 +148,7 @@ class SchemaTests(PostgreSQLTestCase): def test_check_constraint_range_lower_upper(self): constraint = CheckConstraint( - check=Q(ints__startswith__gte=0) & Q(ints__endswith__lte=99), + condition=Q(ints__startswith__gte=0) & Q(ints__endswith__lte=99), name="ints_range_lower_upper", ) msg = f"Constraint “{constraint.name}” is violated." @@ -160,12 +160,12 @@ class SchemaTests(PostgreSQLTestCase): def test_check_constraint_range_lower_with_nulls(self): constraint = CheckConstraint( - check=Q(ints__isnull=True) | Q(ints__startswith__gte=0), + condition=Q(ints__isnull=True) | Q(ints__startswith__gte=0), name="ints_optional_positive_range", ) constraint.validate(RangesModel, RangesModel()) constraint = CheckConstraint( - check=Q(ints__startswith__gte=0), + condition=Q(ints__startswith__gte=0), name="ints_positive_range", ) constraint.validate(RangesModel, RangesModel()) diff --git a/tests/postgres_tests/test_operations.py b/tests/postgres_tests/test_operations.py index bc2ae42096..5780348251 100644 --- a/tests/postgres_tests/test_operations.py +++ b/tests/postgres_tests/test_operations.py @@ -496,7 +496,7 @@ class AddConstraintNotValidTests(OperationTestBase): def test_add(self): table_name = f"{self.app_label}_pony" constraint_name = "pony_pink_gte_check" - constraint = CheckConstraint(check=Q(pink__gte=4), name=constraint_name) + constraint = CheckConstraint(condition=Q(pink__gte=4), name=constraint_name) operation = AddConstraintNotValid("Pony", constraint=constraint) project_state, new_state = self.make_test_state(self.app_label, operation) self.assertEqual( @@ -549,7 +549,7 @@ class ValidateConstraintTests(OperationTestBase): def test_validate(self): constraint_name = "pony_pink_gte_check" - constraint = CheckConstraint(check=Q(pink__gte=4), name=constraint_name) + constraint = CheckConstraint(condition=Q(pink__gte=4), name=constraint_name) operation = AddConstraintNotValid("Pony", constraint=constraint) project_state, new_state = self.make_test_state(self.app_label, operation) Pony = new_state.apps.get_model(self.app_label, "Pony") |
