add force_permissive to Values.is_default_owner
This commit is contained in:
parent
da89c1aa58
commit
35ffde841b
|
@ -1,5 +1,6 @@
|
||||||
Mon Mar 7 16:10:30 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
|
Mon Mar 7 16:10:30 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||||
* force_store_value is now used directly when configuration is loaded
|
* 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>
|
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
|
* requires could be apply to a slave and properties could be different
|
||||||
|
|
|
@ -49,6 +49,12 @@ def test_hidden_owner():
|
||||||
cfg = Config(descr)
|
cfg = Config(descr)
|
||||||
cfg.read_write()
|
cfg.read_write()
|
||||||
raises(PropertiesOptionError, "cfg.getowner(gcdummy)")
|
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():
|
def test_addowner():
|
||||||
|
@ -57,10 +63,12 @@ def test_addowner():
|
||||||
cfg = Config(descr)
|
cfg = Config(descr)
|
||||||
assert cfg.dummy is False
|
assert cfg.dummy is False
|
||||||
assert cfg.getowner(gcdummy) == 'default'
|
assert cfg.getowner(gcdummy) == 'default'
|
||||||
|
assert cfg.cfgimpl_get_values().is_default_owner(gcdummy)
|
||||||
owners.addowner("gen_config")
|
owners.addowner("gen_config")
|
||||||
cfg.cfgimpl_get_settings().setowner(owners.gen_config)
|
cfg.cfgimpl_get_settings().setowner(owners.gen_config)
|
||||||
cfg.dummy = True
|
cfg.dummy = True
|
||||||
assert cfg.getowner(gcdummy) == owners.gen_config
|
assert cfg.getowner(gcdummy) == owners.gen_config
|
||||||
|
assert not cfg.cfgimpl_get_values().is_default_owner(gcdummy)
|
||||||
|
|
||||||
|
|
||||||
def test_addowner_multiple_time():
|
def test_addowner_multiple_time():
|
||||||
|
|
|
@ -531,7 +531,8 @@ class Values(object):
|
||||||
self._p_.setowner(path, owner, index=index)
|
self._p_.setowner(path, owner, index=index)
|
||||||
|
|
||||||
def is_default_owner(self, opt, validate_properties=True,
|
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
|
:param config: *must* be only the **parent** config
|
||||||
(not the toplevel config)
|
(not the toplevel config)
|
||||||
|
@ -540,17 +541,18 @@ class Values(object):
|
||||||
path = opt.impl_getpath(self._getcontext())
|
path = opt.impl_getpath(self._getcontext())
|
||||||
return self._is_default_owner(opt, path,
|
return self._is_default_owner(opt, path,
|
||||||
validate_properties=validate_properties,
|
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,
|
def _is_default_owner(self, opt, path, validate_properties=True,
|
||||||
validate_meta=True, self_properties=undefined,
|
validate_meta=True, self_properties=undefined,
|
||||||
index=None):
|
index=None, force_permissive=False):
|
||||||
if not opt.impl_is_master_slaves('slave'):
|
if not opt.impl_is_master_slaves('slave'):
|
||||||
index = None
|
index = None
|
||||||
d = self._getowner(opt, path, validate_properties,
|
d = self._getowner(opt, path, validate_properties,
|
||||||
validate_meta=validate_meta,
|
validate_meta=validate_meta,
|
||||||
self_properties=self_properties, only_default=True,
|
self_properties=self_properties, only_default=True,
|
||||||
index=index)
|
index=index, force_permissive=force_permissive)
|
||||||
return d == owners.default
|
return d == owners.default
|
||||||
|
|
||||||
def reset_cache(self, only_expired):
|
def reset_cache(self, only_expired):
|
||||||
|
|
Loading…
Reference in New Issue