diff --git a/tests/test_leadership.py b/tests/test_leadership.py index 3b4f2a8..3f8c34a 100644 --- a/tests/test_leadership.py +++ b/tests/test_leadership.py @@ -298,6 +298,32 @@ async def test_groups_with_leader_make_dict(config_type): assert not await list_sessions() +@pytest.mark.asyncio +async def test_groups_with_leader_make_dict2(config_type): + ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True) + netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True) + interface1 = Leadership('other', '', [ip_admin_eth0, netmask_admin_eth0]) + od = OptionDescription('root', '', [interface1]) + async with await Config(od) as cfg: + cfg = await get_config(cfg, config_type) + assert await cfg.value.dict() == {'other.ip_admin_eth0': [], 'other.netmask_admin_eth0': []} + assert await cfg.value.dict(leader_to_list=True) == {'other.ip_admin_eth0': []} + if config_type != 'tiramisu-api': + # FIXME useful? already in leadership + assert await cfg.option('other.ip_admin_eth0').value.len() == 0 + assert await cfg.option('other.netmask_admin_eth0').value.len() == 0 + await cfg.option('other.ip_admin_eth0').value.set(['ip1', 'ip2']) + if config_type != 'tiramisu-api': + # FIXME + assert await cfg.option('other.ip_admin_eth0').value.len() == 2 + assert await cfg.option('other.netmask_admin_eth0').value.len() == 2 + assert await cfg.value.dict() == {'other.ip_admin_eth0': ['ip1', 'ip2'], 'other.netmask_admin_eth0': [None, None]} + assert await cfg.value.dict(leader_to_list=True) == {'other.ip_admin_eth0': [{'other.ip_admin_eth0': 'ip1', 'other.netmask_admin_eth0': None}, {'other.ip_admin_eth0': 'ip2', 'other.netmask_admin_eth0': None}]} + if config_type == 'tiramisu-api': + await cfg.send() + assert not await list_sessions() + + @pytest.mark.asyncio async def test_groups_with_leader_default_value(config_type): ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True) diff --git a/tiramisu/config.py b/tiramisu/config.py index 399eeee..a9bf14d 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -421,7 +421,8 @@ class SubConfig: flatten, fullpath, pathsvalues, - leader_to_list) + leader_to_list, + ) return pathsvalues async def _make_dict(self, @@ -442,7 +443,7 @@ class SubConfig: config_bag) loption_bag.properties = await self.cfgimpl_get_settings().getproperties(loption_bag) leader_pathsvalues = {} - leader_currpath = _currpath + [leader.impl_getname()] + leader_currpath = _currpath + [opt.impl_getname()] await self._make_sub_dict(leader_pathsvalues, leader_currpath, loption_bag,