Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
17f72c2e
Commit
17f72c2e
authored
May 02, 2012
by
Jelte Jansen
Browse files
[1520] treat non-existent list item as empty list
instead of treating it as an error
parent
2f7b1a18
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/python/isc/config/config_data.py
View file @
17f72c2e
...
...
@@ -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
...
...
src/lib/python/isc/config/tests/config_data_test.py
View file @
17f72c2e
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment