diff --git a/ChangeLog b/ChangeLog index 7614f2f..45e2762 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ Mon Dec 1 22:58:13 2014 +0200 Emmanuel Garette * propertyerror are transitive in consistency, now it's possible to set non-transitive consistency * if consistency with multiple option return if transitive + * can reset slave value in all case when deleting master value Sun Oct 26 08:50:38 2014 +0200 Emmanuel Garette * if option is frozen with force_default_on_freeze property, owner diff --git a/test/test_parsing_group.py b/test/test_parsing_group.py index 16f76e8..404b0bb 100644 --- a/test/test_parsing_group.py +++ b/test/test_parsing_group.py @@ -202,6 +202,23 @@ def test_groups_with_master_hidden_in_config2(): cfg.getattr('netmask_admin_eth0', force_permissive=True) cfg.getattr('ip_admin_eth0') raises(PropertiesOptionError, "cfg.getattr('netmask_admin_eth0')") + cfg.ip_admin_eth0.append('192.168.1.1') + assert cfg.ip_admin_eth0 == ['192.168.1.1'] + raises(PropertiesOptionError, "cfg.netmask_admin_eth0") + del(cfg.ip_admin_eth0) + assert cfg.ip_admin_eth0 == [] + #del + cfg.ip_admin_eth0.append('192.168.1.1') + assert cfg.ip_admin_eth0 == ['192.168.1.1'] + cfg.cfgimpl_get_settings().remove('hidden') + assert cfg.netmask_admin_eth0 == [None] + cfg.netmask_admin_eth0 = ['255.255.255.0'] + assert cfg.netmask_admin_eth0 == ['255.255.255.0'] + cfg.cfgimpl_get_settings().append('hidden') + del(cfg.ip_admin_eth0) + cfg.ip_admin_eth0.append('192.168.1.1') + cfg.cfgimpl_get_settings().remove('hidden') + assert cfg.netmask_admin_eth0 == [None] def test_groups_with_master_hidden_in_config3(): @@ -219,7 +236,6 @@ def test_groups_with_master_hidden_in_config3(): raises(PropertiesOptionError, "cfg.getattr('netmask_admin_eth0')") - def test_allowed_groups(): 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) @@ -310,6 +326,13 @@ def test_reset_values_with_master_and_slaves(): assert cfg.getowner(netmask_admin_eth0) == owners.default assert cfg.ip_admin_eth0.ip_admin_eth0 == [] assert cfg.ip_admin_eth0.netmask_admin_eth0 == [] + #reset + cfg.ip_admin_eth0.ip_admin_eth0.append("192.168.230.145") + cfg.cfgimpl_get_values().reset(ip_admin_eth0) + assert cfg.getowner(ip_admin_eth0) == owners.default + assert cfg.getowner(netmask_admin_eth0) == 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(): @@ -333,6 +356,11 @@ def test_values_with_master_and_slaves_slave(): 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(SlaveError, 'cfg.ip_admin_eth0.netmask_admin_eth0.pop(1)') + #reset + cfg.ip_admin_eth0.ip_admin_eth0.append("192.168.230.145") + cfg.cfgimpl_get_values().reset(ip_admin_eth0) + assert cfg.ip_admin_eth0.ip_admin_eth0 == [] + assert cfg.ip_admin_eth0.netmask_admin_eth0 == [] def test_values_with_master_and_slaves_master(): diff --git a/tiramisu/option/masterslave.py b/tiramisu/option/masterslave.py index 4bffab7..cef4c04 100644 --- a/tiramisu/option/masterslave.py +++ b/tiramisu/option/masterslave.py @@ -100,9 +100,9 @@ class MasterSlaves(object): else: # pragma: no dynoptiondescription cover return opt == self.master or opt in self.slaves - def reset(self, opt, values, validate): + def reset(self, opt, values): for slave in self.getslaves(opt): - values.reset(slave, validate=validate) + values.reset(slave, validate=False) def pop(self, opt, values, index): for slave in self.getslaves(opt): diff --git a/tiramisu/value.py b/tiramisu/value.py index 582d337..326540c 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -165,7 +165,7 @@ class Values(object): context, 'validator' in setting) context.cfgimpl_reset_cache() if opt.impl_is_master_slaves('master'): - opt.impl_get_master_slaves().reset(opt, self, validate) + opt.impl_get_master_slaves().reset(opt, self) self._p_.resetvalue(path) def _isempty(self, opt, value):