calc_value: remove duplicate value even if use join
This commit is contained in:
parent
4b41fd89fb
commit
8b4ceddb81
2 changed files with 13 additions and 1 deletions
|
@ -1514,6 +1514,18 @@ async def test_calc_value_remove_duplicate(config_type):
|
||||||
assert not await list_sessions()
|
assert not await list_sessions()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_calc_value_remove_duplicate2(config_type):
|
||||||
|
val1 = StrOption('val1', "", ['val1', 'val1'], multi=True, properties=('notunique',))
|
||||||
|
val2 = StrOption('val2', "", ['val1', 'val1'], multi=True, properties=('notunique',))
|
||||||
|
val3 = StrOption('val3', "", Calculation(calc_value, Params((ParamOption(val1), ParamOption(val2)), multi=ParamValue(True), remove_duplicate_value=ParamValue(True), join=ParamValue('-'))), multi=True)
|
||||||
|
od = OptionDescription('root', '', [val1, val2, val3])
|
||||||
|
async with await Config(od) as cfg:
|
||||||
|
cfg = await get_config(cfg, config_type)
|
||||||
|
assert await cfg.value.dict() == {'val1': ['val1', 'val1'], 'val2': ['val1', 'val1'], 'val3': ['val1-val1']}
|
||||||
|
assert not await list_sessions()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_calc_value_join(config_type):
|
async def test_calc_value_join(config_type):
|
||||||
val1 = StrOption('val1', "", 'val1')
|
val1 = StrOption('val1', "", 'val1')
|
||||||
|
|
|
@ -361,7 +361,7 @@ class CalcValue:
|
||||||
value = []
|
value = []
|
||||||
elif None in value and not allow_none:
|
elif None in value and not allow_none:
|
||||||
value = []
|
value = []
|
||||||
elif remove_duplicate_value:
|
if remove_duplicate_value:
|
||||||
new_value = []
|
new_value = []
|
||||||
for val in value:
|
for val in value:
|
||||||
if val not in new_value:
|
if val not in new_value:
|
||||||
|
|
Loading…
Reference in a new issue