diff options
Diffstat (limited to 'tests/invalid_models_tests/test_deprecated_fields.py')
| -rw-r--r-- | tests/invalid_models_tests/test_deprecated_fields.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_deprecated_fields.py b/tests/invalid_models_tests/test_deprecated_fields.py index 3f3953496c..7b1e3fb7ac 100644 --- a/tests/invalid_models_tests/test_deprecated_fields.py +++ b/tests/invalid_models_tests/test_deprecated_fields.py @@ -85,3 +85,65 @@ class DeprecatedFieldsTests(SimpleTestCase): ), ], ) + + @skipUnless(connection.vendor == "postgresql", "PostgreSQL specific SQL") + def test_postgres_ci_fields_deprecated(self): + from django.contrib.postgres.fields import ( + ArrayField, + CICharField, + CIEmailField, + CITextField, + ) + + class PostgresCIFieldsModel(models.Model): + ci_char = CICharField(max_length=255) + ci_email = CIEmailField() + ci_text = CITextField() + array_ci_text = ArrayField(CITextField()) + + self.assertEqual( + PostgresCIFieldsModel.check(), + [ + checks.Warning( + "django.contrib.postgres.fields.CICharField is deprecated. Support " + "for it (except in historical migrations) will be removed in " + "Django 5.1.", + hint=( + 'Use CharField(db_collation="…") with a case-insensitive ' + "non-deterministic collation instead." + ), + obj=PostgresCIFieldsModel._meta.get_field("ci_char"), + id="fields.W905", + ), + checks.Warning( + "django.contrib.postgres.fields.CIEmailField is deprecated. " + "Support for it (except in historical migrations) will be removed " + "in Django 5.1.", + hint=( + 'Use EmailField(db_collation="…") with a case-insensitive ' + "non-deterministic collation instead." + ), + obj=PostgresCIFieldsModel._meta.get_field("ci_email"), + id="fields.W906", + ), + checks.Warning( + "django.contrib.postgres.fields.CITextField is deprecated. Support " + "for it (except in historical migrations) will be removed in " + "Django 5.1.", + hint=( + 'Use TextField(db_collation="…") with a case-insensitive ' + "non-deterministic collation instead." + ), + obj=PostgresCIFieldsModel._meta.get_field("ci_text"), + id="fields.W907", + ), + checks.Warning( + "Base field for array has warnings:\n" + " django.contrib.postgres.fields.CITextField is deprecated. " + "Support for it (except in historical migrations) will be removed " + "in Django 5.1. (fields.W907)", + obj=PostgresCIFieldsModel._meta.get_field("array_ci_text"), + id="postgres.W004", + ), + ], + ) |
