add test test_validator_params_value_values_kwargs_empty
This commit is contained in:
@ -81,6 +81,10 @@ def value_values_index2(value, values, index, auto=False):
|
||||
value == 'val2' and values == ['val1', 'val2'] and index == 'val'):
|
||||
raise ValueError('error')
|
||||
|
||||
def value_empty(value, empty, values):
|
||||
if not value == 'val' or empty is not False and not values == ['val']:
|
||||
raise ValueError('error')
|
||||
|
||||
|
||||
def test_validator():
|
||||
opt1 = StrOption('opt1', '', validator=return_true, default='val')
|
||||
@ -176,6 +180,24 @@ def test_validator_params_value_values_notmulti():
|
||||
raises(TypeError, "opt1 = StrOption('opt1', '', validator=value_values, default='val')")
|
||||
|
||||
|
||||
def test_validator_params_value_values_kwargs_empty():
|
||||
v = BoolOption('v', '', default=False)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True, default=["ip"])
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0',
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
validator=value_empty,
|
||||
validator_params={'': ((v, False),)})
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [v, interface1])
|
||||
cfg = Config(root)
|
||||
assert cfg.ip_admin_eth0.ip_admin_eth0 == ['ip']
|
||||
cfg.ip_admin_eth0.netmask_admin_eth0[0] = 'val'
|
||||
#cfg.ip_admin_eth0.ip_admin_eth0.append('val')
|
||||
#cfg.ip_admin_eth0.netmask_admin_eth0[1] = 'val2'
|
||||
|
||||
|
||||
def test_validator_params_value_values_kwargs():
|
||||
v = BoolOption('v', '', default=False)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True, default=["ip"])
|
||||
|
Reference in New Issue
Block a user