exected could be a list
This commit is contained in:
parent
d3d4de7ae3
commit
0bb066a8b8
|
@ -1070,6 +1070,38 @@ async def test_requires_different_inverse_unicode(config_type):
|
|||
assert not await list_sessions()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_requires_different_inverse_unicode2(config_type):
|
||||
a = BoolOption('activate_service', '', False)
|
||||
d = StrOption('activate_other_service', '', 'val2')
|
||||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition_0': ParamOption(a),
|
||||
'condition_1': ParamOption(d),
|
||||
'expected_0': ParamValue(True),
|
||||
'expected_1': ParamValue(['val2', 'val3']),
|
||||
'condition_operator': ParamValue('OR'),
|
||||
'reverse_condition_1': ParamValue(True)}))
|
||||
b = IPOption('ip_address_service', '', properties=(disabled_property,))
|
||||
od = OptionDescription('service', '', [a, d, b])
|
||||
async with await Config(od) as cfg:
|
||||
await cfg.property.read_write()
|
||||
cfg = await get_config(cfg, config_type)
|
||||
assert await cfg.option('ip_address_service').value.get() == None
|
||||
await cfg.option('activate_service').value.set(True)
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
await cfg.option('ip_address_service').value.get()
|
||||
await cfg.option('activate_service').value.set(False)
|
||||
assert await cfg.option('ip_address_service').value.get() == None
|
||||
await cfg.option('activate_other_service').value.set('val1')
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
await cfg.option('ip_address_service').value.get()
|
||||
await cfg.option('activate_service').value.set(True)
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
await cfg.option('ip_address_service').value.get()
|
||||
assert not await list_sessions()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_optiondescription_requires():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
|
|
|
@ -501,5 +501,4 @@ async def calculate(option,
|
|||
'').format(str(error),
|
||||
callback.__name__,
|
||||
option.impl_get_display_name())
|
||||
del error
|
||||
raise ConfigError(msg)
|
||||
raise ConfigError(msg) from error
|
||||
|
|
|
@ -400,6 +400,9 @@ class CalcValue:
|
|||
for idx, calculated_condition in calculated_conditions.items():
|
||||
if isinstance(calculated_expected, dict):
|
||||
if idx is not None:
|
||||
if isinstance(calculated_expected[idx], list):
|
||||
current_matches = calculated_condition in calculated_expected[idx]
|
||||
else:
|
||||
current_matches = calculated_condition == calculated_expected[idx]
|
||||
else:
|
||||
current_matches = calculated_condition in calculated_expected.values()
|
||||
|
|
Loading…
Reference in New Issue