calc_value with join parameter now work if an option is empty
This commit is contained in:
parent
96c76286db
commit
dc8010f0af
@ -1433,11 +1433,14 @@ async def test_calc_value_remove_duplicate(config_type):
|
||||
async def test_calc_value_join(config_type):
|
||||
val1 = StrOption('val1', "", 'val1')
|
||||
val2 = StrOption('val2', "", 'val2')
|
||||
val3 = StrOption('val3', "", Calculation(calc_value, Params((ParamOption(val1), ParamOption(val2)), join=ParamValue('.'))))
|
||||
od = OptionDescription('root', '', [val1, val2, val3])
|
||||
val3 = StrOption('val3', "")
|
||||
val4 = StrOption('val4', "", Calculation(calc_value, Params((ParamOption(val1), ParamOption(val2), ParamOption(val3)), join=ParamValue('.'))))
|
||||
od = OptionDescription('root', '', [val1, val2, val3, val4])
|
||||
async with await Config(od) as cfg:
|
||||
cfg = await get_config(cfg, config_type)
|
||||
assert await cfg.value.dict() == {'val1': 'val1', 'val2': 'val2', 'val3': 'val1.val2'}
|
||||
assert await cfg.value.dict() == {'val1': 'val1', 'val2': 'val2', 'val3': None, 'val4': None}
|
||||
await cfg.option('val3').value.set('val3')
|
||||
assert await cfg.value.dict() == {'val1': 'val1', 'val2': 'val2', 'val3': 'val3', 'val4': 'val1.val2.val3'}
|
||||
assert not await list_sessions()
|
||||
|
||||
|
||||
|
@ -311,7 +311,10 @@ class CalcValue:
|
||||
min_args_len)
|
||||
if not multi:
|
||||
if join is not None:
|
||||
value = join.join(value)
|
||||
if None not in value:
|
||||
value = join.join(value)
|
||||
else:
|
||||
value = None
|
||||
elif value and operator:
|
||||
new_value = value[0]
|
||||
op = {'mul': mul,
|
||||
|
Loading…
Reference in New Issue
Block a user