update help() in api
This commit is contained in:
@ -17,7 +17,7 @@ ICON = u'\u2937'
|
||||
OPTIONS_TYPE = {'str': {'type': str,
|
||||
'option': StrOption}
|
||||
}
|
||||
PROPERTIES = ['hidden', 'disabled']
|
||||
PROPERTIES = ['hidden', 'disabled', 'mandatory']
|
||||
PROPERTIES_LIST = ['prop1', 'prop2']
|
||||
|
||||
OWNER = 'user'
|
||||
@ -1068,7 +1068,7 @@ def autocheck_option_get(api, pathread, pathwrite, confread, confwrite, **kwargs
|
||||
name = pathread.rsplit('.', 1)[1]
|
||||
else:
|
||||
name = pathread
|
||||
assert api.option.get(pathread).impl_getname() == name
|
||||
assert api.unrestraint.option(pathread).option.name() == name
|
||||
|
||||
|
||||
@autocheck
|
||||
@ -1088,28 +1088,28 @@ def autocheck_find(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
name = pathread.rsplit('.', 1)[1]
|
||||
else:
|
||||
name = pathread
|
||||
option = _getoption(api.option.get(pathread))
|
||||
option = _getoption(api.unrestraint.option(pathread).option.get())
|
||||
|
||||
def do(conf):
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert option == _getoption(api.config(conf).option.find_first(name))
|
||||
assert option == _getoption(api.forcepermissive.config(conf).option.find_first(name))
|
||||
assert option == _getoption(api.config(conf).option.find(name, first=True))
|
||||
assert option == _getoption(api.forcepermissive.config(conf).option.find(name, first=True))
|
||||
elif kwargs.get('permissive', False):
|
||||
raises(AttributeError, "api.config(conf).option.find_first(name)")
|
||||
assert option == _getoption(api.forcepermissive.config(conf).option.find_first(name))
|
||||
raises(AttributeError, "api.config(conf).option.find(name, first=True)")
|
||||
assert option == _getoption(api.forcepermissive.config(conf).option.find(name, first=True))
|
||||
else:
|
||||
raises(AttributeError, "api.config(conf).option.find_first(name)")
|
||||
raises(AttributeError, "api.forcepermissive.config(conf).option.find_first(name)")
|
||||
assert option == _getoption(api.unrestraint.config(conf).option.find_first(name))
|
||||
raises(AttributeError, "api.config(conf).option.find(name, first=True)")
|
||||
raises(AttributeError, "api.forcepermissive.config(conf).option.find(name, first=True)")
|
||||
assert option == _getoption(api.unrestraint.config(conf).option.find(name, first=True))
|
||||
assert [option] == _getoptions(api.unrestraint.config(conf).option.find(name))
|
||||
assert pathread == api.unrestraint.config(conf).option.find_first(name, 'path')
|
||||
assert pathread == api.unrestraint.config(conf).option.find(name, 'path', first=True)
|
||||
assert [pathread] == api.unrestraint.config(conf).option.find(name, 'path')
|
||||
do(confread)
|
||||
if confread != confwrite:
|
||||
do(confwrite)
|
||||
|
||||
|
||||
def check_all(cfg, paths, path, meta, multi, default, default_multi, require, consistency, callback, symlink, weakrefs, **kwargs):
|
||||
def check_all(cfg, paths_, path, meta, multi, default, default_multi, require, consistency, callback, symlink, weakrefs, **kwargs):
|
||||
def _build_make_dict():
|
||||
dico = {}
|
||||
dico_value = {}
|
||||
@ -1132,7 +1132,7 @@ def check_all(cfg, paths, path, meta, multi, default, default_multi, require, co
|
||||
is_master = False
|
||||
dyns = []
|
||||
has_value = False
|
||||
for cpath, options in paths.items():
|
||||
for cpath, options in paths_.items():
|
||||
if options is None:
|
||||
break
|
||||
if '.' in cpath:
|
||||
@ -1172,7 +1172,7 @@ def check_all(cfg, paths, path, meta, multi, default, default_multi, require, co
|
||||
kwargs['default'] = None
|
||||
if is_dyn and dyns:
|
||||
idx = 0
|
||||
for cpath in list(paths.keys())[len(dyns):]:
|
||||
for cpath in list(paths_.keys())[len(dyns):]:
|
||||
if dyns[idx]:
|
||||
dico[cpath] = default_value
|
||||
if symlink:
|
||||
@ -1227,7 +1227,7 @@ def check_all(cfg, paths, path, meta, multi, default, default_multi, require, co
|
||||
dico[cpath + 'extraoptconsistency'] = value
|
||||
dico_value[cpath + 'extraoptconsistency'] = value
|
||||
if is_master:
|
||||
for cpath in list(paths.keys())[len(dyns):]:
|
||||
for cpath in list(paths_.keys())[len(dyns):]:
|
||||
if cpath.endswith('.first') or cpath.endswith('.firstval1') or cpath.endswith('.firstval2'):
|
||||
second_path = cpath.rsplit('.', 1)[0] + '.second'
|
||||
third_path = cpath.rsplit('.', 1)[0] + '.third'
|
||||
@ -1698,6 +1698,8 @@ def paths(request):
|
||||
|
||||
def test_options(paths):
|
||||
def get_kwargs_option(options, kwargs, od=False):
|
||||
if options.get('mandatory', False):
|
||||
kwargs['mandatory'] = True
|
||||
if options.get('hidden', False) is True:
|
||||
kwargs['permissive'] = True
|
||||
if not od:
|
Reference in New Issue
Block a user