api: valid properties in get_option
This commit is contained in:
parent
cf3e8cded9
commit
73d27af971
|
@ -82,7 +82,7 @@ def autocheck_option_multi(api, pathread, pathwrite, confread, confwrite, **kwar
|
|||
raises(PropertiesOptionError, "api.option(pathread).option.issubmulti()")
|
||||
raises(PropertiesOptionError, "api.option(pathread).option.ismaster()")
|
||||
raises(PropertiesOptionError, "api.option(pathread).option.isslave()")
|
||||
#
|
||||
|
||||
if not kwargs.get('propertyerror', False):
|
||||
api.forcepermissive.option(pathread).option.ismulti()
|
||||
api.forcepermissive.option(pathread).option.issubmulti()
|
||||
|
@ -93,7 +93,7 @@ def autocheck_option_multi(api, pathread, pathwrite, confread, confwrite, **kwar
|
|||
raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.issubmulti()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.ismaster()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.isslave()")
|
||||
#
|
||||
|
||||
api.unrestraint.option(pathread).option.ismulti()
|
||||
api.unrestraint.option(pathread).option.issubmulti()
|
||||
api.unrestraint.option(pathread).option.ismaster()
|
||||
|
@ -126,6 +126,9 @@ def autocheck_default_owner(api, pathread, pathwrite, confread, confwrite, **kwa
|
|||
#
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.isdefault()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).owner.isdefault()")
|
||||
#
|
||||
assert api.unrestraint.config(conf).option(pathread).owner.get() == 'default'
|
||||
assert api.unrestraint.config(conf).option(pathread).owner.isdefault()
|
||||
else:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert api.config(conf).option(pathread, 0).owner.get() == 'default'
|
||||
|
@ -145,10 +148,8 @@ def autocheck_default_owner(api, pathread, pathwrite, confread, confwrite, **kwa
|
|||
#
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread, 0).owner.isdefault()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread, 0).owner.isdefault()")
|
||||
|
||||
# unrestraint is not allowed
|
||||
raises(APIError, "api.unrestraint.config(conf).option(pathread).owner.get()")
|
||||
raises(APIError, "api.unrestraint.config(conf).option(pathread).owner.isdefault()")
|
||||
assert api.unrestraint.config(conf).option(pathread, 0).owner.get() == 'default'
|
||||
assert api.unrestraint.config(conf).option(pathread, 0).owner.isdefault()
|
||||
do(confread)
|
||||
if confread != confwrite:
|
||||
do(confwrite)
|
||||
|
@ -401,7 +402,7 @@ def autocheck_value_slave(api, pathread, pathwrite, confread, confwrite, **kwarg
|
|||
isslave = api.unrestraint.option(pathread).option.isslave()
|
||||
if not isslave:
|
||||
if kwargs.get('propertyerror', False):
|
||||
raises(APIError, "api.config(confread).option(pathread).value.len()")
|
||||
raises(APIError, "api.unrestraint.config(confread).option(pathread).value.len()")
|
||||
return
|
||||
if kwargs.get('propertyerror', False):
|
||||
raises(PropertiesOptionError, "api.option(pathread).value.len()")
|
||||
|
@ -650,12 +651,12 @@ def _check_properties(api, pathread, conf, kwargs, props_permissive, props):
|
|||
else:
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).property.get()")
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).property.get()")
|
||||
if kwargs.get('propertyerror', False):
|
||||
if not kwargs.get('propertyerror', False):
|
||||
assert set(api.forcepermissive.config(conf).option(pathread).property.get()) == set(props_permissive)
|
||||
assert set(api.forcepermissive.config(conf).option(pathread).property.get()) == set(props)
|
||||
else:
|
||||
assert(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).property.get()")
|
||||
assert(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).property.get()")
|
||||
assert PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).property.get()"
|
||||
assert PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).property.get()"
|
||||
assert set(api.unrestraint.config(conf).option(pathread).property.get()) == set(props_permissive)
|
||||
assert set(api.unrestraint.config(conf).option(pathread).property.get()) == set(props)
|
||||
else:
|
||||
|
@ -671,7 +672,7 @@ def _check_properties(api, pathread, conf, kwargs, props_permissive, props):
|
|||
#
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread, 1).property.get()")
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread, 1).property.get()")
|
||||
if kwargs.get('propertyerror', False):
|
||||
if not kwargs.get('propertyerror', False):
|
||||
assert set(api.forcepermissive.config(conf).option(pathread, 0).property.get()) == set(props_permissive)
|
||||
assert set(api.forcepermissive.config(conf).option(pathread, 0).property.get()) == set(props)
|
||||
#
|
||||
|
@ -706,7 +707,7 @@ def autocheck_property(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
|||
|
||||
# set properties without permissive
|
||||
for prop in properties:
|
||||
api.config(confwrite).option(pathwrite).property.add(prop)
|
||||
api.unrestraint.config(confwrite).option(pathwrite).property.add(prop)
|
||||
_check_properties(api, pathread, confread, kwargs, properties, properties)
|
||||
if confread != confwrite:
|
||||
_check_properties(api, pathread, confwrite, kwargs, properties, properties)
|
||||
|
@ -737,7 +738,9 @@ def _property_permissive(api, pathread, pathwrite, confread, confwrite, **kwargs
|
|||
|
||||
# set properties with permissive
|
||||
for prop in properties:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
api.config(confwrite).option(pathwrite).property.add(prop)
|
||||
if not kwargs.get('propertyerror', False):
|
||||
api.forcepermissive.config(confwrite).option(pathwrite).property.add(prop)
|
||||
api.unrestraint.config(confwrite).option(pathwrite).property.add(prop)
|
||||
|
||||
|
@ -763,7 +766,7 @@ def autocheck_reset_property(api, pathread, pathwrite, confread, confwrite, **kw
|
|||
_property_permissive(api, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||
|
||||
# reset properties without permissive
|
||||
api.config(confwrite).option(pathwrite).property.reset()
|
||||
api.unrestraint.config(confwrite).option(pathwrite).property.reset()
|
||||
|
||||
_check_properties(api, pathread, confread, kwargs, default_props, default_props)
|
||||
if confread != confwrite:
|
||||
|
@ -780,8 +783,8 @@ def autocheck_reset_property_permissive(api, pathread, pathwrite, confread, conf
|
|||
_property_permissive(api, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||
|
||||
for prop in properties:
|
||||
api.forcepermissive.option(pathwrite).property.add(prop)
|
||||
api.forcepermissive.option(pathwrite).property.reset()
|
||||
api.unrestraint.option(pathwrite).property.add(prop)
|
||||
api.unrestraint.option(pathwrite).property.reset()
|
||||
|
||||
_check_properties(api, pathread, confwrite, kwargs, default_props, default_props)
|
||||
if confread != confwrite:
|
||||
|
@ -1626,63 +1629,63 @@ def make_conf(options, meta, multi, default, default_multi, require, consistency
|
|||
|
||||
|
||||
DICT_PATHS = [
|
||||
##test a config without optiondescription
|
||||
#OrderedDict([('first', {}),
|
||||
# ('second', {'second': {'disabled': True}}),
|
||||
# ('third', {'third': {'hidden': True}})
|
||||
# ]),
|
||||
##test a config with two optiondescription
|
||||
#OrderedDict([('subod.subsubod.first', {}),
|
||||
# ('subod.subsubod.second', {'second': {'disabled': True}}),
|
||||
# ('subod.subsubod.third', {'third': {'hidden': True}})]),
|
||||
##test a config with masterslaves
|
||||
#OrderedDict([('odmaster.first', {'odmaster': {'master': True}}),
|
||||
# ('odmaster.second', {'odmaster': {'master': True}, 'second': {'disabled': True, 'slave': True}}),
|
||||
# ('odmaster.third', {'odmaster': {'master': True}, 'third': {'hidden': True, 'slave': True}})]),
|
||||
##test a config with dynoption
|
||||
#OrderedDict([('subod.first', {'subod': {'dyn': True}}),
|
||||
# ('subod.second', {'second': {'disabled': True}}),
|
||||
# ('subod.third', {'third': {'hidden': True}}),
|
||||
# ('subodval1.firstval1', None),
|
||||
# ('subodval1.secondval1', None),
|
||||
# ('subodval1.thirdval1', None),
|
||||
# ('subodval2.firstval2', None),
|
||||
# ('subodval2.secondval2', None),
|
||||
# ('subodval2.thirdval2', None)]),
|
||||
##test a config with dynoption subdir
|
||||
#OrderedDict([('subod.subsubod.first', {'subsubod': {'dyn': True}}),
|
||||
# ('subod.subsubod.second', {'subsubod': {'dyn': True}, 'second': {'disabled': True}}),
|
||||
# ('subod.subsubod.third', {'subsubod': {'dyn': True}, 'third': {'hidden': True}}),
|
||||
# ('subod.subsubodval1.firstval1', None),
|
||||
# ('subod.subsubodval1.secondval1', None),
|
||||
# ('subod.subsubodval1.thirdval1', None),
|
||||
# ('subod.subsubodval2.firstval2', None),
|
||||
# ('subod.subsubodval2.secondval2', None),
|
||||
# ('subod.subsubodval2.thirdval2', None)]),
|
||||
##test a config with hidden subsubod
|
||||
#test a config without optiondescription
|
||||
OrderedDict([('first', {}),
|
||||
('second', {'second': {'disabled': True}}),
|
||||
('third', {'third': {'hidden': True}})
|
||||
]),
|
||||
#test a config with two optiondescription
|
||||
OrderedDict([('subod.subsubod.first', {}),
|
||||
('subod.subsubod.second', {'second': {'disabled': True}}),
|
||||
('subod.subsubod.third', {'third': {'hidden': True}})]),
|
||||
#test a config with masterslaves
|
||||
OrderedDict([('odmaster.first', {'odmaster': {'master': True}}),
|
||||
('odmaster.second', {'odmaster': {'master': True}, 'second': {'disabled': True, 'slave': True}}),
|
||||
('odmaster.third', {'odmaster': {'master': True}, 'third': {'hidden': True, 'slave': True}})]),
|
||||
#test a config with dynoption
|
||||
OrderedDict([('subod.first', {'subod': {'dyn': True}}),
|
||||
('subod.second', {'second': {'disabled': True}}),
|
||||
('subod.third', {'third': {'hidden': True}}),
|
||||
('subodval1.firstval1', None),
|
||||
('subodval1.secondval1', None),
|
||||
('subodval1.thirdval1', None),
|
||||
('subodval2.firstval2', None),
|
||||
('subodval2.secondval2', None),
|
||||
('subodval2.thirdval2', None)]),
|
||||
#test a config with dynoption subdir
|
||||
OrderedDict([('subod.subsubod.first', {'subsubod': {'dyn': True}}),
|
||||
('subod.subsubod.second', {'subsubod': {'dyn': True}, 'second': {'disabled': True}}),
|
||||
('subod.subsubod.third', {'subsubod': {'dyn': True}, 'third': {'hidden': True}}),
|
||||
('subod.subsubodval1.firstval1', None),
|
||||
('subod.subsubodval1.secondval1', None),
|
||||
('subod.subsubodval1.thirdval1', None),
|
||||
('subod.subsubodval2.firstval2', None),
|
||||
('subod.subsubodval2.secondval2', None),
|
||||
('subod.subsubodval2.thirdval2', None)]),
|
||||
#test a config with hidden subsubod
|
||||
OrderedDict([('subod.subsubod.first', {'subsubod': {'hidden': True}}),
|
||||
('subod.subsubod.second', {'subsubod': {'hidden': True}}),
|
||||
('subod.subsubod.third', {'subsubod': {'hidden': True}})]),
|
||||
##test a config with hidden dyn subsubod
|
||||
#OrderedDict([('subod.subsubod.first', {'subsubod': {'dyn': True, 'hidden': True}}),
|
||||
# ('subod.subsubod.second', {'subsubod': {'dyn': True, 'hidden': True}}),
|
||||
# ('subod.subsubod.third', {'subsubod': {'dyn': True, 'hidden': True}}),
|
||||
# ('subod.subsubodval1.firstval1', None),
|
||||
# ('subod.subsubodval1.secondval1', None),
|
||||
# ('subod.subsubodval1.thirdval1', None),
|
||||
# ('subod.subsubodval2.firstval2', None),
|
||||
# ('subod.subsubodval2.secondval2', None),
|
||||
# ('subod.subsubodval2.thirdval2', None)]),
|
||||
##test a config with dyn subsubod with masterslave
|
||||
#OrderedDict([('subod.subsubod.first', {'subod': {'dyn': True}, 'subsubod': {'master': True}}),
|
||||
# ('subod.subsubod.second', {'subod': {'dyn': True}, 'subsubod' : {'master': True}, 'second': {'disabled': True, 'slave': True}}),
|
||||
# ('subod.subsubod.third', {'subod': {'dyn': True}, 'subsubod': {'master': True}, 'third': {'hidden': True, 'slave': True}}),
|
||||
# ('subodval1.subsubodval1.firstval1', None),
|
||||
# ('subodval1.subsubodval1.secondval1', None),
|
||||
# ('subodval1.subsubodval1.thirdval1', None),
|
||||
# ('subodval2.subsubodval2.firstval2', None),
|
||||
# ('subodval2.subsubodval2.secondval2', None),
|
||||
# ('subodval2.subsubodval2.thirdval2', None)]),
|
||||
#test a config with hidden dyn subsubod
|
||||
OrderedDict([('subod.subsubod.first', {'subsubod': {'dyn': True, 'hidden': True}}),
|
||||
('subod.subsubod.second', {'subsubod': {'dyn': True, 'hidden': True}}),
|
||||
('subod.subsubod.third', {'subsubod': {'dyn': True, 'hidden': True}}),
|
||||
('subod.subsubodval1.firstval1', None),
|
||||
('subod.subsubodval1.secondval1', None),
|
||||
('subod.subsubodval1.thirdval1', None),
|
||||
('subod.subsubodval2.firstval2', None),
|
||||
('subod.subsubodval2.secondval2', None),
|
||||
('subod.subsubodval2.thirdval2', None)]),
|
||||
#test a config with dyn subsubod with masterslave
|
||||
OrderedDict([('subod.subsubod.first', {'subod': {'dyn': True}, 'subsubod': {'master': True}}),
|
||||
('subod.subsubod.second', {'subod': {'dyn': True}, 'subsubod' : {'master': True}, 'second': {'disabled': True, 'slave': True}}),
|
||||
('subod.subsubod.third', {'subod': {'dyn': True}, 'subsubod': {'master': True}, 'third': {'hidden': True, 'slave': True}}),
|
||||
('subodval1.subsubodval1.firstval1', None),
|
||||
('subodval1.subsubodval1.secondval1', None),
|
||||
('subodval1.subsubodval1.thirdval1', None),
|
||||
('subodval2.subsubodval2.firstval2', None),
|
||||
('subodval2.subsubodval2.secondval2', None),
|
||||
('subodval2.subsubodval2.thirdval2', None)]),
|
||||
]
|
||||
|
||||
|
||||
|
@ -1718,26 +1721,26 @@ def test_options(paths):
|
|||
|
||||
lpaths = list(paths.keys())
|
||||
|
||||
# for meta in (False, True):
|
||||
# for callback in (False, True):
|
||||
# for consistency in (False, True):
|
||||
# for require in (False, True):
|
||||
# for default_multi in (False, True):
|
||||
# for symlink in (False, True):
|
||||
# if callback and default_multi:
|
||||
# continue
|
||||
# for default in (False, True):
|
||||
# for multi in (False, True, submulti):
|
||||
for meta in (False,):
|
||||
for callback in (False,):
|
||||
for consistency in (False,):
|
||||
for require in (False,):
|
||||
for default_multi in (False,):
|
||||
for symlink in (False,):
|
||||
for meta in (False, True):
|
||||
for callback in (False, True):
|
||||
for consistency in (False, True):
|
||||
for require in (False, True):
|
||||
for default_multi in (False, True):
|
||||
for symlink in (False, True):
|
||||
if callback and default_multi:
|
||||
continue
|
||||
for default in (False,):
|
||||
for multi in (False,):
|
||||
for default in (False, True):
|
||||
for multi in (False, True, submulti):
|
||||
# for meta in (False,):
|
||||
# for callback in (False,):
|
||||
# for consistency in (False,):
|
||||
# for require in (False,):
|
||||
# for default_multi in (False,):
|
||||
# for symlink in (False,):
|
||||
# if callback and default_multi:
|
||||
# continue
|
||||
# for default in (False,):
|
||||
# for multi in (False,):
|
||||
if multi is submulti and default:
|
||||
continue
|
||||
if multi is submulti and consistency:
|
||||
|
|
|
@ -90,6 +90,10 @@ class CommonTiramisu(object):
|
|||
self.config_bag,
|
||||
self.subconfig)
|
||||
self.config_bag.option = option
|
||||
if self.config_bag.setting_properties:
|
||||
self.config_bag.config.cfgimpl_get_settings().validate_properties(self.path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
if self.index is not None and option.impl_is_master_slaves('slave') and \
|
||||
self.index >= self.subconfig.cfgimpl_get_length():
|
||||
raise SlaveError(_('index "{}" is higher than the master length "{}" '
|
||||
|
|
Loading…
Reference in New Issue