diff options
| author | Simon Charette <charette.s@gmail.com> | 2017-05-03 01:25:30 -0400 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2017-05-04 00:02:14 -0400 |
| commit | b91868507af08234a30e9a8e7c90b37c561ba315 (patch) | |
| tree | 332ff103ffcc30c800ffa5df968113b32acd9447 /tests/postgres_tests | |
| parent | f37467ec7a970e3cb9f9f25c370c4072fc994a6e (diff) | |
Fixed #28161 -- Fixed return type of ArrayField(CITextField()).
Thanks Tim for the review.
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/__init__.py | 6 | ||||
| -rw-r--r-- | tests/postgres_tests/migrations/0002_create_test_models.py | 1 | ||||
| -rw-r--r-- | tests/postgres_tests/models.py | 1 | ||||
| -rw-r--r-- | tests/postgres_tests/test_citext.py | 8 |
4 files changed, 13 insertions, 3 deletions
diff --git a/tests/postgres_tests/__init__.py b/tests/postgres_tests/__init__.py index 9396b7fe80..24d78c9bfe 100644 --- a/tests/postgres_tests/__init__.py +++ b/tests/postgres_tests/__init__.py @@ -12,14 +12,14 @@ class PostgreSQLTestCase(TestCase): @classmethod def tearDownClass(cls): # No need to keep that signal overhead for non PostgreSQL-related tests. - from django.contrib.postgres.signals import register_hstore_handler + from django.contrib.postgres.signals import register_type_handlers - connection_created.disconnect(register_hstore_handler) + connection_created.disconnect(register_type_handlers) super().tearDownClass() @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests") # To locate the widget's template. @modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'}) -class PostgreSQLWidgetTestCase(WidgetTest): +class PostgreSQLWidgetTestCase(WidgetTest, PostgreSQLTestCase): pass diff --git a/tests/postgres_tests/migrations/0002_create_test_models.py b/tests/postgres_tests/migrations/0002_create_test_models.py index 8cbd95c3bb..1cb6fe686e 100644 --- a/tests/postgres_tests/migrations/0002_create_test_models.py +++ b/tests/postgres_tests/migrations/0002_create_test_models.py @@ -142,6 +142,7 @@ class Migration(migrations.Migration): ('name', CICharField(primary_key=True, max_length=255)), ('email', CIEmailField()), ('description', CITextField()), + ('array_field', ArrayField(CITextField(), null=True)), ], options={ 'required_db_vendor': 'postgresql', diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py index e1c276890c..fcfd85f8e7 100644 --- a/tests/postgres_tests/models.py +++ b/tests/postgres_tests/models.py @@ -106,6 +106,7 @@ class CITestModel(PostgreSQLModel): name = CICharField(primary_key=True, max_length=255) email = CIEmailField() description = CITextField() + array_field = ArrayField(CITextField(), null=True) def __str__(self): return self.name diff --git a/tests/postgres_tests/test_citext.py b/tests/postgres_tests/test_citext.py index f99f3bfa47..0a7012b072 100644 --- a/tests/postgres_tests/test_citext.py +++ b/tests/postgres_tests/test_citext.py @@ -4,11 +4,13 @@ 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.test.utils import modify_settings from . import PostgreSQLTestCase from .models import CITestModel +@modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'}) class CITextTestCase(PostgreSQLTestCase): @classmethod @@ -17,6 +19,7 @@ class CITextTestCase(PostgreSQLTestCase): name='JoHn', email='joHn@johN.com', description='Average Joe named JoHn', + array_field=['JoE', 'jOhn'], ) def test_equal_lowercase(self): @@ -34,3 +37,8 @@ class CITextTestCase(PostgreSQLTestCase): """ 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()) |
