master groups that have multis
This commit is contained in:
parent
a404c4c992
commit
29914051e0
|
@ -82,21 +82,34 @@ def test_iter_on_empty_group():
|
||||||
pass
|
pass
|
||||||
assert [] == list(config)
|
assert [] == list(config)
|
||||||
|
|
||||||
|
def test_groups_with_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)
|
||||||
|
assert interface1.get_group_type() == groups.master
|
||||||
|
|
||||||
def test_allowed_groups():
|
def test_allowed_groups():
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé")
|
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")
|
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 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
raises(ConfigError, "interface1.set_group_type('toto')")
|
raises(ConfigError, "interface1.set_group_type('toto')")
|
||||||
|
|
||||||
def test_master_not_valid_name():
|
def test_master_not_valid_name():
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé")
|
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")
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||||
invalid_group = OptionDescription('interface1', '', [ip_admin_eth0, netmask_admin_eth0])
|
invalid_group = OptionDescription('interface1', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
raises(ConfigError, "invalid_group.set_group_type(groups.master)")
|
raises(ConfigError, "invalid_group.set_group_type(groups.master)")
|
||||||
|
|
||||||
def test_sub_group_in_master_group():
|
def test_sub_group_in_master_group():
|
||||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé")
|
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")
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||||
subgroup = OptionDescription("subgroup", '', [])
|
subgroup = OptionDescription("subgroup", '', [])
|
||||||
invalid_group = OptionDescription('ip_admin_eth0', '', [subgroup, ip_admin_eth0, netmask_admin_eth0])
|
invalid_group = OptionDescription('ip_admin_eth0', '', [subgroup, ip_admin_eth0, netmask_admin_eth0])
|
||||||
raises(ConfigError, "invalid_group.set_group_type(groups.master)")
|
raises(ConfigError, "invalid_group.set_group_type(groups.master)")
|
||||||
|
|
||||||
|
def test_group_has_always_multis():
|
||||||
|
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")
|
||||||
|
group = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||||
|
raises(ConfigError, "group.set_group_type(groups.master)")
|
||||||
|
|
|
@ -489,7 +489,11 @@ class OptionDescription(HiddenBaseType, DisabledBaseType):
|
||||||
for child in self._children:
|
for child in self._children:
|
||||||
if isinstance(child, OptionDescription):
|
if isinstance(child, OptionDescription):
|
||||||
raise ConfigError("master group {} shall not have "
|
raise ConfigError("master group {} shall not have "
|
||||||
"a subgroup".format(self._name))
|
"a subgroup".format(self._name))
|
||||||
|
if not child.multi:
|
||||||
|
raise ConfigError("not allowed option {0} in group {1}"
|
||||||
|
": this option is not a multi".format(child._name,
|
||||||
|
self._name))
|
||||||
if child._name == self._name:
|
if child._name == self._name:
|
||||||
identical_master_child_name = True
|
identical_master_child_name = True
|
||||||
if not identical_master_child_name:
|
if not identical_master_child_name:
|
||||||
|
|
Loading…
Reference in New Issue