add a test with default_multi for a submulti follower
This commit is contained in:
parent
f7bd6e3a47
commit
f437bb78f3
1 changed files with 25 additions and 21 deletions
|
@ -5,7 +5,6 @@ import pytest
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
|
||||||
from tiramisu.api import TIRAMISU_VERSION
|
|
||||||
from tiramisu.setting import groups, owners
|
from tiramisu.setting import groups, owners
|
||||||
from tiramisu import StrOption, IntOption, OptionDescription, submulti, Leadership, Config, \
|
from tiramisu import StrOption, IntOption, OptionDescription, submulti, Leadership, Config, \
|
||||||
MetaConfig, undefined, Params, ParamOption, Calculation
|
MetaConfig, undefined, Params, ParamOption, Calculation
|
||||||
|
@ -38,11 +37,7 @@ async def test_unknown_multi():
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_submulti():
|
async def test_submulti():
|
||||||
multi = StrOption('multi', '', multi=submulti)
|
multi = StrOption('multi', '', multi=submulti)
|
||||||
if TIRAMISU_VERSION == 2:
|
multi2 = StrOption('multi2', '', default_multi=['yes'], multi=submulti)
|
||||||
default_multi = 'yes'
|
|
||||||
else:
|
|
||||||
default_multi = ['yes']
|
|
||||||
multi2 = StrOption('multi2', '', default_multi=default_multi, multi=submulti)
|
|
||||||
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
||||||
od = OptionDescription('od', '', [multi, multi2, multi3])
|
od = OptionDescription('od', '', [multi, multi2, multi3])
|
||||||
async with await Config(od) as cfg:
|
async with await Config(od) as cfg:
|
||||||
|
@ -66,11 +61,7 @@ async def test_submulti_default_multi_not_list():
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_append_submulti():
|
async def test_append_submulti():
|
||||||
multi = StrOption('multi', '', multi=submulti)
|
multi = StrOption('multi', '', multi=submulti)
|
||||||
if TIRAMISU_VERSION == 2:
|
multi2 = StrOption('multi2', '', default_multi=['yes'], multi=submulti)
|
||||||
default_multi = 'yes'
|
|
||||||
else:
|
|
||||||
default_multi = ['yes']
|
|
||||||
multi2 = StrOption('multi2', '', default_multi=default_multi, multi=submulti)
|
|
||||||
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
||||||
od = OptionDescription('od', '', [multi, multi2, multi3])
|
od = OptionDescription('od', '', [multi, multi2, multi3])
|
||||||
async with await Config(od) as cfg:
|
async with await Config(od) as cfg:
|
||||||
|
@ -104,11 +95,7 @@ async def test_append_submulti():
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_append_unvalide_submulti():
|
async def test_append_unvalide_submulti():
|
||||||
multi = StrOption('multi', '', multi=submulti)
|
multi = StrOption('multi', '', multi=submulti)
|
||||||
if TIRAMISU_VERSION == 2:
|
multi2 = StrOption('multi2', '', default_multi=['yes'], multi=submulti)
|
||||||
default_multi = 'yes'
|
|
||||||
else:
|
|
||||||
default_multi = ['yes']
|
|
||||||
multi2 = StrOption('multi2', '', default_multi=default_multi, multi=submulti)
|
|
||||||
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
||||||
od = OptionDescription('od', '', [multi, multi2, multi3])
|
od = OptionDescription('od', '', [multi, multi2, multi3])
|
||||||
async with await Config(od) as cfg:
|
async with await Config(od) as cfg:
|
||||||
|
@ -137,11 +124,7 @@ async def test_append_unvalide_submulti():
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_pop_submulti():
|
async def test_pop_submulti():
|
||||||
multi = StrOption('multi', '', multi=submulti)
|
multi = StrOption('multi', '', multi=submulti)
|
||||||
if TIRAMISU_VERSION == 2:
|
multi2 = StrOption('multi2', '', default_multi=['yes'], multi=submulti)
|
||||||
default_multi = 'yes'
|
|
||||||
else:
|
|
||||||
default_multi = ['yes']
|
|
||||||
multi2 = StrOption('multi2', '', default_multi=default_multi, multi=submulti)
|
|
||||||
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
multi3 = StrOption('multi3', '', default=[['yes']], multi=submulti)
|
||||||
od = OptionDescription('od', '', [multi, multi2, multi3])
|
od = OptionDescription('od', '', [multi, multi2, multi3])
|
||||||
async with await Config(od) as cfg:
|
async with await Config(od) as cfg:
|
||||||
|
@ -267,6 +250,27 @@ async def test_values_with_leader_and_followers_submulti():
|
||||||
assert not await list_sessions()
|
assert not await list_sessions()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_values_with_leader_and_followers_submulti_default_multi():
|
||||||
|
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=submulti, default_multi=['255.255.0.0', '0.0.0.0'])
|
||||||
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
maconfig = OptionDescription('toto', '', [interface1])
|
||||||
|
async with await Config(maconfig) as cfg:
|
||||||
|
await cfg.property.read_write()
|
||||||
|
owner = await cfg.owner.get()
|
||||||
|
assert interface1.impl_get_group_type() == groups.leadership
|
||||||
|
assert await cfg.option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.default
|
||||||
|
await cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145"])
|
||||||
|
assert await cfg.option('ip_admin_eth0.ip_admin_eth0').value.get() == ["192.168.230.145"]
|
||||||
|
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == ['255.255.0.0', '0.0.0.0']
|
||||||
|
await cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145", "192.168.230.147"])
|
||||||
|
await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(['255.255.255.0'])
|
||||||
|
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == ['255.255.255.0']
|
||||||
|
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == ['255.255.0.0', '0.0.0.0']
|
||||||
|
assert not await list_sessions()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_reset_values_with_leader_and_followers_submulti():
|
async def test_reset_values_with_leader_and_followers_submulti():
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||||
|
|
Loading…
Reference in a new issue