summaryrefslogtreecommitdiff
path: root/tests/postgres_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-09-13 14:03:45 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-09-18 22:12:40 +0200
commit04eb1b4567c96ccb167c16a95ca12c336b0c791b (patch)
tree994b6e77374e28c9e0915c41fec71b4f125773ee /tests/postgres_tests
parent6e4e5523a8f40b63f3e74889266a7d638f6364dc (diff)
Refs #33872 -- Removed django.contrib.postgres.fields.CIText/CICharField/CIEmailField/CITextField.
Per deprecation timeline.
Diffstat (limited to 'tests/postgres_tests')
-rw-r--r--tests/postgres_tests/fields.py6
-rw-r--r--tests/postgres_tests/migrations/0002_create_test_models.py20
-rw-r--r--tests/postgres_tests/models.py11
-rw-r--r--tests/postgres_tests/test_citext.py91
4 files changed, 0 insertions, 128 deletions
diff --git a/tests/postgres_tests/fields.py b/tests/postgres_tests/fields.py
index 1565b5ed43..c2513fca0c 100644
--- a/tests/postgres_tests/fields.py
+++ b/tests/postgres_tests/fields.py
@@ -7,9 +7,6 @@ import enum
from django.db import models
try:
- from django.contrib.postgres.fields import CICharField # RemovedInDjango51Warning.
- from django.contrib.postgres.fields import CIEmailField # RemovedInDjango51Warning.
- from django.contrib.postgres.fields import CITextField # RemovedInDjango51Warning.
from django.contrib.postgres.fields import (
ArrayField,
BigIntegerRangeField,
@@ -47,9 +44,6 @@ except ImportError:
ArrayField = DummyArrayField
BigIntegerRangeField = models.Field
- CICharField = models.Field # RemovedInDjango51Warning.
- CIEmailField = models.Field # RemovedInDjango51Warning.
- CITextField = models.Field # RemovedInDjango51Warning.
DateRangeField = models.Field
DateTimeRangeField = DummyContinuousRangeField
DecimalRangeField = DummyContinuousRangeField
diff --git a/tests/postgres_tests/migrations/0002_create_test_models.py b/tests/postgres_tests/migrations/0002_create_test_models.py
index 011a0d729b..5538b436ad 100644
--- a/tests/postgres_tests/migrations/0002_create_test_models.py
+++ b/tests/postgres_tests/migrations/0002_create_test_models.py
@@ -3,9 +3,6 @@ from django.db import migrations, models
from ..fields import (
ArrayField,
BigIntegerRangeField,
- CICharField,
- CIEmailField,
- CITextField,
DateRangeField,
DateTimeRangeField,
DecimalRangeField,
@@ -290,23 +287,6 @@ class Migration(migrations.Migration):
options=None,
bases=None,
),
- # RemovedInDjango51Warning.
- migrations.CreateModel(
- name="CITestModel",
- fields=[
- (
- "name",
- CICharField(primary_key=True, serialize=False, max_length=255),
- ),
- ("email", CIEmailField()),
- ("description", CITextField()),
- ("array_field", ArrayField(CITextField(), null=True)),
- ],
- options={
- "required_db_vendor": "postgresql",
- },
- bases=None,
- ),
migrations.CreateModel(
name="Line",
fields=[
diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py
index 05f2732fb8..a97894e327 100644
--- a/tests/postgres_tests/models.py
+++ b/tests/postgres_tests/models.py
@@ -3,9 +3,6 @@ from django.db import models
from .fields import (
ArrayField,
BigIntegerRangeField,
- CICharField,
- CIEmailField,
- CITextField,
DateRangeField,
DateTimeRangeField,
DecimalRangeField,
@@ -119,14 +116,6 @@ class Character(models.Model):
name = models.CharField(max_length=255)
-# RemovedInDjango51Warning.
-class CITestModel(PostgreSQLModel):
- name = CICharField(primary_key=True, max_length=255)
- email = CIEmailField()
- description = CITextField()
- array_field = ArrayField(CITextField(), null=True)
-
-
class Line(PostgreSQLModel):
scene = models.ForeignKey("Scene", models.CASCADE)
character = models.ForeignKey("Character", models.CASCADE)
diff --git a/tests/postgres_tests/test_citext.py b/tests/postgres_tests/test_citext.py
deleted file mode 100644
index 2abb56b39f..0000000000
--- a/tests/postgres_tests/test_citext.py
+++ /dev/null
@@ -1,91 +0,0 @@
-# RemovedInDjango51Warning.
-"""
-The citext PostgreSQL extension supports indexing of case-insensitive text
-strings and thus eliminates the need for operations such as iexact and other
-modifiers to enforce use of an index.
-"""
-from django.db import IntegrityError
-from django.utils.deprecation import RemovedInDjango51Warning
-
-from . import PostgreSQLTestCase
-from .models import CITestModel
-
-
-class CITextTestCase(PostgreSQLTestCase):
- case_sensitive_lookups = ("contains", "startswith", "endswith", "regex")
-
- @classmethod
- def setUpTestData(cls):
- cls.john = CITestModel.objects.create(
- name="JoHn",
- email="joHn@johN.com",
- description="Average Joe named JoHn",
- array_field=["JoE", "jOhn"],
- )
-
- def test_equal_lowercase(self):
- """
- citext removes the need for iexact as the index is case-insensitive.
- """
- self.assertEqual(
- CITestModel.objects.filter(name=self.john.name.lower()).count(), 1
- )
- self.assertEqual(
- CITestModel.objects.filter(email=self.john.email.lower()).count(), 1
- )
- self.assertEqual(
- CITestModel.objects.filter(
- description=self.john.description.lower()
- ).count(),
- 1,
- )
-
- def test_fail_citext_primary_key(self):
- """
- Creating an entry for a citext field used as a primary key which
- clashes with an existing value isn't allowed.
- """
- with self.assertRaises(IntegrityError):
- CITestModel.objects.create(name="John")
-
- def test_array_field(self):
- instance = CITestModel.objects.get()
- self.assertEqual(instance.array_field, self.john.array_field)
- self.assertTrue(
- CITestModel.objects.filter(array_field__contains=["joe"]).exists()
- )
-
- def test_lookups_name_char(self):
- for lookup in self.case_sensitive_lookups:
- with self.subTest(lookup=lookup):
- query = {"name__{}".format(lookup): "john"}
- self.assertSequenceEqual(
- CITestModel.objects.filter(**query), [self.john]
- )
-
- def test_lookups_description_text(self):
- for lookup, string in zip(
- self.case_sensitive_lookups, ("average", "average joe", "john", "Joe.named")
- ):
- with self.subTest(lookup=lookup, string=string):
- query = {"description__{}".format(lookup): string}
- self.assertSequenceEqual(
- CITestModel.objects.filter(**query), [self.john]
- )
-
- def test_lookups_email(self):
- for lookup, string in zip(
- self.case_sensitive_lookups, ("john", "john", "john.com", "john.com")
- ):
- with self.subTest(lookup=lookup, string=string):
- query = {"email__{}".format(lookup): string}
- self.assertSequenceEqual(
- CITestModel.objects.filter(**query), [self.john]
- )
-
- def test_citext_deprecated(self):
- from django.contrib.postgres.fields import CIText
-
- msg = "django.contrib.postgres.fields.CIText mixin is deprecated."
- with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
- CIText()