all multi gestion is now in Multi
This commit is contained in:
@ -141,12 +141,17 @@ def test_values_with_master_and_slaves():
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
opt = cfg.unwrap_from_path("ip_admin_eth0.ip_admin_eth0")
|
||||
opt_slave = cfg.unwrap_from_path("ip_admin_eth0.netmask_admin_eth0")
|
||||
owner = cfg._cfgimpl_context._cfgimpl_settings.getowner()
|
||||
assert interface1.get_group_type() == groups.master
|
||||
assert cfg.cfgimpl_get_values().getowner(opt) == owners.default
|
||||
assert cfg.cfgimpl_get_values().getowner(opt_slave) == owners.default
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0 == []
|
||||
cfg.ip_admin_eth0.ip_admin_eth0.append("192.168.230.145")
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == ["192.168.230.145"]
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == ["192.168.230.145"]
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0 == [None]
|
||||
assert cfg.cfgimpl_get_values().getowner(opt) == owner
|
||||
assert cfg.cfgimpl_get_values().getowner(opt_slave) == owners.default
|
||||
|
||||
|
||||
def test_reset_values_with_master_and_slaves():
|
||||
@ -157,11 +162,54 @@ def test_reset_values_with_master_and_slaves():
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
opt = cfg.unwrap_from_path("ip_admin_eth0.ip_admin_eth0")
|
||||
opt_slave = cfg.unwrap_from_path("ip_admin_eth0.netmask_admin_eth0")
|
||||
owner = cfg._cfgimpl_context._cfgimpl_settings.getowner()
|
||||
assert interface1.get_group_type() == groups.master
|
||||
assert cfg.cfgimpl_get_values().getowner(opt) == owners.default
|
||||
assert cfg.cfgimpl_get_values().getowner(opt_slave) == owners.default
|
||||
cfg.ip_admin_eth0.ip_admin_eth0.append("192.168.230.145")
|
||||
assert cfg.cfgimpl_get_values().getowner(opt) == owner
|
||||
assert cfg.cfgimpl_get_values().getowner(opt_slave) == owners.default
|
||||
del(cfg.ip_admin_eth0.ip_admin_eth0)
|
||||
assert cfg.cfgimpl_get_values().getowner(opt) == owners.default
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
assert cfg.cfgimpl_get_values().getowner(opt_slave) == owners.default
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == []
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0 == []
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_slave():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0 == []
|
||||
raises(ValueError, "cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0']")
|
||||
cfg.ip_admin_eth0.ip_admin_eth0.append("192.168.230.145")
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0']
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0[0] = '255.255.255.0'
|
||||
raises(ValueError, "cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0', '255.255.255.0']")
|
||||
raises(ValueError, "cfg.ip_admin_eth0.netmask_admin_eth0 = []")
|
||||
del(cfg.ip_admin_eth0.netmask_admin_eth0)
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0']
|
||||
cfg.ip_admin_eth0.ip_admin_eth0.append("192.168.230.145")
|
||||
assert cfg.ip_admin_eth0.netmask_admin_eth0 == ['255.255.255.0', None]
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0', '255.255.255.0']
|
||||
raises(ValueError, 'cfg.ip_admin_eth0.netmask_admin_eth0.pop(1)')
|
||||
|
||||
|
||||
def test_values_with_master_and_slaves_master():
|
||||
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.set_group_type(groups.master)
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.ip_admin_eth0.ip_admin_eth0.append("192.168.230.145")
|
||||
cfg.ip_admin_eth0.ip_admin_eth0 = ["192.168.230.145"]
|
||||
cfg.ip_admin_eth0.ip_admin_eth0 = ["192.168.230.145", "192.168.230.145"]
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0 = ['255.255.255.0', '255.255.255.0']
|
||||
raises(ValueError, 'cfg.ip_admin_eth0.ip_admin_eth0 = ["192.168.230.145"]')
|
||||
cfg.ip_admin_eth0.ip_admin_eth0.pop(1)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == ["192.168.230.145"]
|
||||
|
Reference in New Issue
Block a user