diff options
| author | Mads Jensen <mje@inducks.org> | 2017-02-11 13:16:35 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-02-11 07:16:35 -0500 |
| commit | fb5bd38e3b83c7f0d1011de80f922fc34faf740b (patch) | |
| tree | 645820c1fc79fdb9e78a40060c5df632706cf247 /tests/postgres_tests/test_citext.py | |
| parent | fe2d2884345e1e6a1daadd76e9404c62791ab589 (diff) | |
Refs #26610 -- Added CIText mixin and CIChar/Email/TextField.
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') |
