summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorvinay karanam <vinayinvicible@users.noreply.github.com>2018-07-27 15:35:54 +0000
committerTim Graham <timograham@gmail.com>2018-07-27 11:35:54 -0400
commit3af695eda24b874486ee8be7e0d729761b3bdc71 (patch)
tree7549619d744e65fe6fa7cadcd1e3f9be6574abf5 /tests/postgres_tests/test_array.py
parent69eb70456bfd42becdbdf1ca6043ae2e3263beb5 (diff)
Fixed #28291, #24726 -- Fixed ArrayField with JSONField and RangeFields.
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index d0e10dcb31..25fbc230bb 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -24,6 +24,7 @@ try:
from django.contrib.postgres.forms import (
SimpleArrayField, SplitArrayField, SplitArrayWidget,
)
+ from psycopg2.extras import NumericRange
except ImportError:
pass
@@ -96,6 +97,12 @@ class TestSaveLoad(PostgreSQLTestCase):
uuids=[uuid.uuid4()],
decimals=[decimal.Decimal(1.25), 1.75],
tags=[Tag(1), Tag(2), Tag(3)],
+ json=[{'a': 1}, {'b': 2}],
+ int_ranges=[NumericRange(10, 20), NumericRange(30, 40)],
+ bigint_ranges=[
+ NumericRange(7000000000, 10000000000),
+ NumericRange(50000000000, 70000000000),
+ ]
)
instance.save()
loaded = OtherTypesArrayModel.objects.get()
@@ -103,6 +110,9 @@ class TestSaveLoad(PostgreSQLTestCase):
self.assertEqual(instance.uuids, loaded.uuids)
self.assertEqual(instance.decimals, loaded.decimals)
self.assertEqual(instance.tags, loaded.tags)
+ self.assertEqual(instance.json, loaded.json)
+ self.assertEqual(instance.int_ranges, loaded.int_ranges)
+ self.assertEqual(instance.bigint_ranges, loaded.bigint_ranges)
def test_null_from_db_value_handling(self):
instance = OtherTypesArrayModel.objects.create(
@@ -113,6 +123,9 @@ class TestSaveLoad(PostgreSQLTestCase):
)
instance.refresh_from_db()
self.assertIsNone(instance.tags)
+ self.assertEqual(instance.json, [])
+ self.assertIsNone(instance.int_ranges)
+ self.assertIsNone(instance.bigint_ranges)
def test_model_set_on_base_field(self):
instance = IntegerArrayModel()