Refs #30907 -- Added more tests for SplitArrayField.has_changed().
This commit is contained in:
parent
6bbf9a20e2
commit
d95b1ddcbe
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue