Commit 7e93ff50 authored by Jelte Jansen's avatar Jelte Jansen

[2184] Fix issue of null default value

Found another issue which became more apparent now (but I think we've seen before); get_default_value() returns None if there is no default set, however, in some cases, None can be the actual default (datasources params for instance).

This fix makes sure a default value of None is not confused with no value at all (which resulted in the error 'Error: data_sources/classes/IN[X]/params not found'
parent fa831b22
......@@ -6,6 +6,15 @@
"item_type": "any",
"item_optional": false,
"item_default": "asdf"
{ "item_name": "item2",
"item_type": "any",
"item_optional": true
{ "item_name": "item3",
"item_type": "any",
"item_optional": true,
"item_default": null
......@@ -556,7 +556,6 @@ class MultiConfigData:
if 'item_default' in spec:
# one special case, named_set
if spec['item_type'] == 'named_set':
print("is " + id_part + " in named set?")
return spec['item_default']
return spec['item_default']
......@@ -585,6 +584,14 @@ class MultiConfigData:
value = self.get_default_value(identifier)
if value is not None:
return value, self.DEFAULT
# get_default_value returns None for both
# the cases where there is no default, and where
# it is set to null, so we need to catch the latter
spec_part = self.find_spec_part(identifier)
if spec_part and 'item_default' in spec_part and\
spec_part['item_default'] is None:
return None, self.DEFAULT
return None, self.NONE
def _append_value_item(self, result, spec_part, identifier, all, first = False):
......@@ -650,7 +657,8 @@ class MultiConfigData:
value, status = self.get_value(identifier)
if status == self.NONE and not spec_part['item_optional']:
if status == self.NONE and not spec_part['item_optional']:# and\
#not ('item_default' in spec_part):
raise + " not found")
entry = _create_value_map_entry(identifier,
......@@ -1020,6 +1020,18 @@ class TestUIModuleCCSession(unittest.TestCase):
uccs.remove_value, "Spec2/item5", None)
# Check that the difference between no default and default = null
# is recognized
def test_default_null(self):
fake_conn = fakeUIConn()
uccs = self.create_uccs(fake_conn, "spec40.spec")
(value, status) = uccs.get_value("/Spec40/item2")
self.assertEqual(uccs.NONE, status)
(value, status) = uccs.get_value("/Spec40/item3")
self.assertEqual(uccs.DEFAULT, status)
# Test adding and removing values for type = any
def test_add_remove_value_any(self):
fake_conn = fakeUIConn()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment