add force_permissive to Values.is_default_owner

This commit is contained in:
Emmanuel Garette 2016-03-07 16:34:36 +01:00
parent da89c1aa58
commit 35ffde841b
3 changed files with 15 additions and 4 deletions

View File

@ -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

View 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():

View 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):