can reset slave value in all case when deleting master value
authorEmmanuel Garette <egarette@cadoles.com>
Mon, 1 Dec 2014 22:08:56 +0000 (23:08 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Mon, 1 Dec 2014 22:08:56 +0000 (23:08 +0100)
ChangeLog
test/test_parsing_group.py
tiramisu/option/masterslave.py
tiramisu/value.py

index 7614f2f..45e2762 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@ Mon Dec  1 22:58:13 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
        * 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 <egarette@cadoles.com>
        * if option is frozen with force_default_on_freeze property, owner
index 16f76e8..404b0bb 100644 (file)
@@ -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():
index 4bffab7..cef4c04 100644 (file)
@@ -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):
index 582d337..326540c 100644 (file)
@@ -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):