mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[1520] treat non-existent list item as empty list
instead of treating it as an error
This commit is contained in:
@@ -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 isc.cc.data.DataNotFoundError(identifier + " 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.mcd.set_specification(module_spec)
|
||||
self.assertRaises(isc.cc.data.DataNotFoundError,
|
||||
self.mcd.get_value_maps, "/Spec24/item", 4)
|
||||
# optional list item that is not set should return as empty list
|
||||
maps = self.mcd.get_value_maps("/Spec24/item", 4)
|
||||
self.assertEqual([{'default': False, 'type': 'list', 'name': 'Spec24/item', 'value': [], 'modified': False}], maps)
|
||||
|
||||
self.mcd._set_current_config({ "Spec24": { "item": [] } })
|
||||
maps = self.mcd.get_value_maps("/Spec24/item")
|
||||
self.assertEqual([{'default': False, 'modified': False, 'name': 'Spec24/item', 'type': 'list', 'value': []}], maps)
|
||||
|
Reference in New Issue
Block a user