summaryrefslogtreecommitdiff
path: root/tests/postgres_tests/test_array.py
diff options
context:
space:
mode:
authorPavel Dedik <pavel.dedik@kiwi.com>2019-10-25 14:39:33 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-28 10:32:05 +0100
commitd95b1ddcbef6ef61229080bab1c166d6ee4a161b (patch)
treec50e7944176ff47efd6f58d1bc05d1ac03e73b79 /tests/postgres_tests/test_array.py
parent6bbf9a20e2c5865e01b537e8cd34dfca06621a4a (diff)
downloaddjango-d95b1ddcbef6ef61229080bab1c166d6ee4a161b.tar.gz
Refs #30907 -- Added more tests for SplitArrayField.has_changed().
Diffstat (limited to 'tests/postgres_tests/test_array.py')
-rw-r--r--tests/postgres_tests/test_array.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 3f54110447..7686ea10a8 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -961,9 +961,19 @@ class TestSplitFormField(PostgreSQLSimpleTestCase):
model = IntegerArrayModel
fields = ('field',)
- obj = IntegerArrayModel(field=[1, 2])
- form = Form({'field_0': '1', 'field_1': '2'}, instance=obj)
- self.assertFalse(form.has_changed())
+ tests = [
+ ({}, {'field_0': '', 'field_1': ''}, True),
+ ({'field': None}, {'field_0': '', 'field_1': ''}, True),
+ ({'field': [1]}, {'field_0': '', 'field_1': ''}, True),
+ ({'field': [1]}, {'field_0': '1', 'field_1': '0'}, True),
+ ({'field': [1, 2]}, {'field_0': '1', 'field_1': '2'}, False),
+ ({'field': [1, 2]}, {'field_0': 'a', 'field_1': 'b'}, True),
+ ]
+ for initial, data, expected_result in tests:
+ with self.subTest(initial=initial, data=data):
+ obj = IntegerArrayModel(**initial)
+ form = Form(data, instance=obj)
+ self.assertIs(form.has_changed(), expected_result)
class TestSplitFormWidget(PostgreSQLWidgetTestCase):