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