add force_permissive in mandatory_warnings
This commit is contained in:
parent
f730050f7c
commit
c75867720f
4 changed files with 22 additions and 7 deletions
|
@ -5,6 +5,8 @@ Sun Oct 26 08:50:38 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
|
|||
* frozen with force_default_on_freeze can change owner
|
||||
* add force_permissive to config __iter__
|
||||
* pass force_permissive to slave for a master or to master for a slave
|
||||
* remove mandatory_warnings in config.py
|
||||
* add force_permissive in mandatory_warnings
|
||||
|
||||
Sat Oct 25 22:48:08 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* cannot add unvalaible consistency for an option
|
||||
|
|
|
@ -211,6 +211,7 @@ def test_mandatory_warnings_ro():
|
|||
config.str = 'a'
|
||||
config.read_only()
|
||||
assert config.cfgimpl_get_values().mandatory_warnings() == ['str1', 'unicode2', 'str3']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3']
|
||||
sleep(.1)
|
||||
|
||||
|
||||
|
@ -223,6 +224,7 @@ def test_mandatory_warnings_rw():
|
|||
assert config.cfgimpl_get_values().mandatory_warnings() == ['str', 'str1', 'unicode2', 'str3']
|
||||
config.str = 'a'
|
||||
assert config.cfgimpl_get_values().mandatory_warnings() == ['str1', 'unicode2', 'str3']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3']
|
||||
sleep(.1)
|
||||
|
||||
|
||||
|
@ -236,9 +238,24 @@ def test_mandatory_warnings_disabled():
|
|||
assert config.cfgimpl_get_values().mandatory_warnings() == ['str', 'str1', 'unicode2', 'str3']
|
||||
setting[descr.str].append('disabled')
|
||||
assert config.cfgimpl_get_values().mandatory_warnings() == ['str1', 'unicode2', 'str3']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3']
|
||||
sleep(.1)
|
||||
|
||||
|
||||
def test_mandatory_warnings_hidden():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
config.cfgimpl_get_settings().setpermissive(('hidden',))
|
||||
config.str
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str', 'str1', 'unicode2', 'str3']
|
||||
setting[descr.str].append('hidden')
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str', 'str1', 'unicode2', 'str3']
|
||||
|
||||
|
||||
def test_mandatory_warnings_frozen():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
|
|
|
@ -734,8 +734,3 @@ class MetaConfig(GroupConfig):
|
|||
child._impl_meta = weakref.ref(self)
|
||||
|
||||
super(MetaConfig, self).__init__(children, session_id, persistent, descr)
|
||||
|
||||
|
||||
def mandatory_warnings(config): # pragma: optional cover
|
||||
#only for retro-compatibility
|
||||
return config.cfgimpl_get_values().mandatory_warnings()
|
||||
|
|
|
@ -441,7 +441,7 @@ class Values(object):
|
|||
raise ValueError(_("information's item"
|
||||
" not found: {0}").format(key))
|
||||
|
||||
def mandatory_warnings(self):
|
||||
def mandatory_warnings(self, force_permissive=False):
|
||||
"""convenience function to trace Options that are mandatory and
|
||||
where no value has been set
|
||||
|
||||
|
@ -462,7 +462,8 @@ class Values(object):
|
|||
path = opt.impl_getpath(self._getcontext())
|
||||
try:
|
||||
self._get_cached_item(opt, path=path,
|
||||
force_properties=frozenset(('mandatory',)))
|
||||
force_properties=frozenset(('mandatory',)),
|
||||
force_permissive=force_permissive)
|
||||
except PropertiesOptionError as err:
|
||||
if err.proptype == ['mandatory']:
|
||||
_ret.append(path)
|
||||
|
|
Loading…
Reference in a new issue