add force_permissive to Values.is_default_owner
authorEmmanuel Garette <egarette@cadoles.com>
Mon, 7 Mar 2016 15:34:36 +0000 (16:34 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Mon, 7 Mar 2016 15:34:36 +0000 (16:34 +0100)
ChangeLog
test/test_option_owner.py
tiramisu/value.py

index fc4aec4..e3c85ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 Mon Mar  7 16:10:30 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
        * force_store_value is now used directly when configuration is loaded
+       * add force_permissive to Values.is_default_owner
 
 Sun Nov 29 23:01:28 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
        * requires could be apply to a slave and properties could be different
index b0b3359..6f88182 100644 (file)
@@ -49,6 +49,12 @@ def test_hidden_owner():
     cfg = Config(descr)
     cfg.read_write()
     raises(PropertiesOptionError, "cfg.getowner(gcdummy)")
+    raises(PropertiesOptionError, "cfg.getowner(gcdummy, force_permissive=True)")
+    raises(PropertiesOptionError, "cfg.cfgimpl_get_values().is_default_owner(gcdummy)")
+    raises(PropertiesOptionError, "cfg.cfgimpl_get_values().is_default_owner(gcdummy, force_permissive=True)")
+    cfg.cfgimpl_get_settings().setpermissive(('hidden',))
+    cfg.getowner(gcdummy, force_permissive=True)
+    cfg.cfgimpl_get_values().is_default_owner(gcdummy, force_permissive=True)
 
 
 def test_addowner():
@@ -57,10 +63,12 @@ def test_addowner():
     cfg = Config(descr)
     assert cfg.dummy is False
     assert cfg.getowner(gcdummy) == 'default'
+    assert cfg.cfgimpl_get_values().is_default_owner(gcdummy)
     owners.addowner("gen_config")
     cfg.cfgimpl_get_settings().setowner(owners.gen_config)
     cfg.dummy = True
     assert cfg.getowner(gcdummy) == owners.gen_config
+    assert not cfg.cfgimpl_get_values().is_default_owner(gcdummy)
 
 
 def test_addowner_multiple_time():
index e7dc6bb..8c32fbc 100644 (file)
@@ -531,7 +531,8 @@ class Values(object):
         self._p_.setowner(path, owner, index=index)
 
     def is_default_owner(self, opt, validate_properties=True,
-                         validate_meta=True, index=None):
+                         validate_meta=True, index=None,
+                         force_permissive=False):
         """
         :param config: *must* be only the **parent** config
                        (not the toplevel config)
@@ -540,17 +541,18 @@ class Values(object):
         path = opt.impl_getpath(self._getcontext())
         return self._is_default_owner(opt, path,
                                       validate_properties=validate_properties,
-                                      validate_meta=validate_meta, index=index)
+                                      validate_meta=validate_meta, index=index,
+                                      force_permissive=force_permissive)
 
     def _is_default_owner(self, opt, path, validate_properties=True,
                           validate_meta=True, self_properties=undefined,
-                          index=None):
+                          index=None, force_permissive=False):
         if not opt.impl_is_master_slaves('slave'):
             index = None
         d = self._getowner(opt, path, validate_properties,
                            validate_meta=validate_meta,
                            self_properties=self_properties, only_default=True,
-                           index=index)
+                           index=index, force_permissive=force_permissive)
         return d == owners.default
 
     def reset_cache(self, only_expired):