summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorFernando Miranda <fcmiranda@gmail.com>2015-07-22 14:51:05 -0300
committerTim Graham <timograham@gmail.com>2016-03-12 09:14:35 -0500
commit2495023a4cae28f494d0a6172abfac3a47a0b816 (patch)
tree720d4f4e7238627b9e8b3a9c9fe3240301bc07c4 /tests/postgres_tests/test_array.py
parentf8d20da0479b88db5bb5a2a30fa769cbf6d0a5bf (diff)
Fixed #25143 -- Added ArrayField.from_db_value().
Thanks Karan Lyons for contributing to the patch.
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 5df25c1c0f..f5c333e56f 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -15,7 +15,7 @@ from . import PostgreSQLTestCase
from .models import (
ArrayFieldSubclass, CharArrayModel, DateTimeArrayModel, IntegerArrayModel,
NestedIntegerArrayModel, NullableIntegerArrayModel, OtherTypesArrayModel,
- PostgreSQLModel,
+ PostgreSQLModel, Tag,
)
try:
@@ -92,12 +92,24 @@ class TestSaveLoad(PostgreSQLTestCase):
ips=['192.168.0.1', '::1'],
uuids=[uuid.uuid4()],
decimals=[decimal.Decimal(1.25), 1.75],
+ tags=[Tag(1), Tag(2), Tag(3)],
)
instance.save()
loaded = OtherTypesArrayModel.objects.get()
self.assertEqual(instance.ips, loaded.ips)
self.assertEqual(instance.uuids, loaded.uuids)
self.assertEqual(instance.decimals, loaded.decimals)
+ self.assertEqual(instance.tags, loaded.tags)
+
+ def test_null_from_db_value_handling(self):
+ instance = OtherTypesArrayModel.objects.create(
+ ips=['192.168.0.1', '::1'],
+ uuids=[uuid.uuid4()],
+ decimals=[decimal.Decimal(1.25), 1.75],
+ tags=None,
+ )
+ instance.refresh_from_db()
+ self.assertIsNone(instance.tags)
def test_model_set_on_base_field(self):
instance = IntegerArrayModel()
@@ -306,11 +318,13 @@ class TestOtherTypesExactQuerying(PostgreSQLTestCase):
self.ips = ['192.168.0.1', '::1']
self.uuids = [uuid.uuid4()]
self.decimals = [decimal.Decimal(1.25), 1.75]
+ self.tags = [Tag(1), Tag(2), Tag(3)]
self.objs = [
OtherTypesArrayModel.objects.create(
ips=self.ips,
uuids=self.uuids,
decimals=self.decimals,
+ tags=self.tags,
)
]
@@ -332,6 +346,12 @@ class TestOtherTypesExactQuerying(PostgreSQLTestCase):
self.objs
)
+ def test_exact_tags(self):
+ self.assertSequenceEqual(
+ OtherTypesArrayModel.objects.filter(tags=self.tags),
+ self.objs
+ )
+
@isolate_apps('postgres_tests')
class TestChecks(PostgreSQLTestCase):