Commit 17f72c2e authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[1520] treat non-existent list item as empty list

instead of treating it as an error
parent 2f7b1a18
......@@ -579,8 +579,10 @@ class MultiConfigData:
if item_type == "list" and (all or first):
spec_part_list = spec_part['list_item_spec']
list_value, status = self.get_value(identifier)
# If not set, and no default, lists will show up as 'None',
# but it's better to treat it as an empty list then
if list_value is None:
raise + " not found")
list_value = []
if type(list_value) != list:
# the identifier specified a single element
......@@ -585,8 +585,10 @@ class TestMultiConfigData(unittest.TestCase):
module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec24.spec")
self.assertRaises(,, "/Spec24/item", 4)
# optional list item that is not set should return as empty list
maps ="/Spec24/item", 4)
self.assertEqual([{'default': False, 'type': 'list', 'name': 'Spec24/item', 'value': [], 'modified': False}], maps){ "Spec24": { "item": [] } })
maps ="/Spec24/item")
self.assertEqual([{'default': False, 'modified': False, 'name': 'Spec24/item', 'type': 'list', 'value': []}], maps)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment