diff options
Diffstat (limited to 'tests/postgres_tests/test_citext.py')
| -rw-r--r-- | tests/postgres_tests/test_citext.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/postgres_tests/test_citext.py b/tests/postgres_tests/test_citext.py index 7f86f6a205..f99f3bfa47 100644 --- a/tests/postgres_tests/test_citext.py +++ b/tests/postgres_tests/test_citext.py @@ -6,25 +6,31 @@ modifiers to enforce use of an index. from django.db import IntegrityError from . import PostgreSQLTestCase -from .models import CITextTestModel +from .models import CITestModel class CITextTestCase(PostgreSQLTestCase): @classmethod def setUpTestData(cls): - CITextTestModel.objects.create(name='JoHn') + cls.john = CITestModel.objects.create( + name='JoHn', + email='joHn@johN.com', + description='Average Joe named JoHn', + ) def test_equal_lowercase(self): """ citext removes the need for iexact as the index is case-insensitive. """ - self.assertEqual(CITextTestModel.objects.filter(name='john').count(), 1) + 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_case(self): + def test_fail_citext_primary_key(self): """ - Creating an entry for a citext-field which clashes with an existing - value isn't allowed. + 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): - CITextTestModel.objects.create(name='John') + CITestModel.objects.create(name='John') |
