Add ParamSelfInformation
This commit is contained in:
@ -10,7 +10,7 @@ from tiramisu.setting import groups, owners
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption, Leadership, \
|
||||
undefined, Calculation, Params, ParamOption, ParamValue, ParamIndex, calc_value, \
|
||||
valid_ip_netmask, ParamSelfOption, ParamInformation
|
||||
valid_ip_netmask, ParamSelfOption, ParamInformation, ParamSelfInformation
|
||||
from tiramisu.error import PropertiesOptionError, ConflictError, LeadershipError, ConfigError
|
||||
from tiramisu.i18n import _
|
||||
from tiramisu.storage import list_sessions
|
||||
@ -378,6 +378,28 @@ async def test_callback_information(config_type):
|
||||
await cfg.information.set('information', 'new_value')
|
||||
assert await cfg.option('val1').value.get() == 'new_value'
|
||||
assert await cfg.option('val2').value.get() == 'new_value'
|
||||
await cfg.information.set('information', 'new_value2')
|
||||
assert await cfg.option('val1').value.get() == 'new_value2'
|
||||
assert await cfg.option('val2').value.get() == 'new_value2'
|
||||
assert not await list_sessions()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_callback_information2(config_type):
|
||||
val1 = StrOption('val1', "", Calculation(return_value, Params(ParamSelfInformation('information', 'no_value'))))
|
||||
val2 = StrOption('val2', "", Calculation(return_value, Params(ParamSelfInformation('information'))))
|
||||
val2.impl_set_information('information', 'new_value')
|
||||
val3 = StrOption('val3', "", Calculation(return_value, Params(ParamSelfInformation('information'))))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3])
|
||||
async with await Config(maconfig) as cfg:
|
||||
await cfg.property.read_write()
|
||||
cfg = await get_config(cfg, config_type)
|
||||
assert await cfg.option('val1').value.get() == 'no_value'
|
||||
assert await cfg.option('val2').value.get() == 'new_value'
|
||||
with pytest.raises(ConfigError):
|
||||
await cfg.option('val3').value.get()
|
||||
await cfg.option('val2').information.set('information', 'new_value2')
|
||||
assert await cfg.option('val2').value.get() == 'new_value2'
|
||||
assert not await list_sessions()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user