some corrections
This commit is contained in:
parent
eba178cdee
commit
790115c919
|
@ -9,7 +9,7 @@ do_autopath()
|
|||
from tiramisu import Config, MetaConfig, \
|
||||
StrOption, SymLinkOption, OptionDescription, MasterSlaves, DynOptionDescription, \
|
||||
getapi, submulti, undefined, owners
|
||||
from tiramisu.error import PropertiesOptionError, APIError, ConfigError
|
||||
from tiramisu.error import PropertiesOptionError, APIError, ConfigError, SlaveError
|
||||
from tiramisu.api import display_count
|
||||
from collections import OrderedDict
|
||||
ICON = u'\u2937'
|
||||
|
@ -77,46 +77,27 @@ def autocheck_option_multi(api, pathread, pathwrite, confread, confwrite, **kwar
|
|||
api.option(pathread).option.issubmulti()
|
||||
api.option(pathread).option.ismaster()
|
||||
api.option(pathread).option.isslave()
|
||||
#
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.option(pathread).option.ismulti()")
|
||||
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()
|
||||
api.forcepermissive.option(pathread).option.ismaster()
|
||||
api.forcepermissive.option(pathread).option.isslave()
|
||||
#
|
||||
api.unrestraint.option(pathread).option.ismulti()
|
||||
api.unrestraint.option(pathread).option.issubmulti()
|
||||
api.unrestraint.option(pathread).option.ismaster()
|
||||
api.unrestraint.option(pathread).option.isslave()
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
#raises(PropertiesOptionError, "api.option(pathread).option.ismulti()")
|
||||
#raises(PropertiesOptionError, "api.option(pathread).option.issubmulti()")
|
||||
#raises(PropertiesOptionError, "api.option(pathread).option.ismaster()")
|
||||
#raises(PropertiesOptionError, "api.option(pathread).option.isslave()")
|
||||
#
|
||||
api.forcepermissive.option(pathread).option.ismulti()
|
||||
api.forcepermissive.option(pathread).option.issubmulti()
|
||||
api.forcepermissive.option(pathread).option.ismaster()
|
||||
api.forcepermissive.option(pathread).option.isslave()
|
||||
#
|
||||
api.unrestraint.option(pathread).option.ismulti()
|
||||
api.unrestraint.option(pathread).option.issubmulti()
|
||||
api.unrestraint.option(pathread).option.ismaster()
|
||||
api.unrestraint.option(pathread).option.isslave()
|
||||
#else:
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.ismulti()")
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.issubmulti()")
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.ismaster()")
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.isslave()")
|
||||
# #
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.ismulti()")
|
||||
# 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()
|
||||
# api.unrestraint.option(pathread).option.isslave()
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.ismulti()")
|
||||
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()
|
||||
api.unrestraint.option(pathread).option.isslave()
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -134,17 +115,17 @@ def autocheck_default_owner(api, pathread, pathwrite, confread, confwrite, **kwa
|
|||
assert api.config(conf).option(pathread).owner.isdefault()
|
||||
assert api.forcepermissive.config(conf).option(pathread).owner.isdefault()
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
#raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.get()")
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.get()")
|
||||
assert api.forcepermissive.config(conf).option(pathread).owner.get() == 'default'
|
||||
#
|
||||
#raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.isdefault()")
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.isdefault()")
|
||||
assert api.forcepermissive.config(conf).option(pathread).owner.isdefault()
|
||||
#else:
|
||||
# raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.get()")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).owner.get()")
|
||||
# #
|
||||
# raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.isdefault()")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).owner.isdefault()")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.get()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).owner.get()")
|
||||
#
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.isdefault()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.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'
|
||||
|
@ -166,8 +147,8 @@ def autocheck_default_owner(api, pathread, pathwrite, confread, confwrite, **kwa
|
|||
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()")
|
||||
raises(APIError, "api.unrestraint.config(conf).option(pathread).owner.get()")
|
||||
raises(APIError, "api.unrestraint.config(conf).option(pathread).owner.isdefault()")
|
||||
do(confread)
|
||||
if confread != confwrite:
|
||||
do(confwrite)
|
||||
|
@ -256,7 +237,8 @@ def _set_value(api, pathwrite, conf, **kwargs):
|
|||
raises(PropertiesOptionError, "api.config(conf).option(pathwrite).value.set([first_value[0]])")
|
||||
raises(PropertiesOptionError,
|
||||
"api.forcepermissive.config(conf).option(pathwrite).value.set([first_value[0]])")
|
||||
raises(APIError, "api.unrestraint.config(conf).option(pathwrite).value.set(first_value[1])")
|
||||
if len(first_value) > 1:
|
||||
raises(APIError, "api.unrestraint.config(conf).option(pathwrite).value.set(first_value[1])")
|
||||
elif isslave:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not set_permissive:
|
||||
|
@ -287,7 +269,7 @@ def _set_value(api, pathwrite, conf, **kwargs):
|
|||
else:
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathwrite).value.set(first_value)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathwrite).value.set(first_value)")
|
||||
#raises(APIError, "api.unrestraint.config(conf).option(pathwrite).value.set(first_value)")
|
||||
#FIXME raises(APIError, "api.unrestraint.config(conf).option(pathwrite).value.set(first_value)")
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -418,7 +400,8 @@ def autocheck_get_value(api, pathread, pathwrite, confread, confwrite, **kwargs)
|
|||
def autocheck_value_slave(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
isslave = api.unrestraint.option(pathread).option.isslave()
|
||||
if not isslave:
|
||||
#FIXME raises(APIError, "api.config(confread).option(pathread).value.len()")
|
||||
if kwargs.get('propertyerror', False):
|
||||
raises(APIError, "api.config(confread).option(pathread).value.len()")
|
||||
return
|
||||
if kwargs.get('propertyerror', False):
|
||||
raises(PropertiesOptionError, "api.option(pathread).value.len()")
|
||||
|
@ -453,14 +436,14 @@ def autocheck_value_slave(api, pathread, pathwrite, confread, confwrite, **kwarg
|
|||
else:
|
||||
value = SUBLIST_FIRST_VALUE[0]
|
||||
|
||||
raises(IndexError, "api.forcepermissive.option(pathread, length).value.get()")
|
||||
raises(IndexError, "api.forcepermissive.option(pathread, length).value.set(value)")
|
||||
raises(IndexError, "api.forcepermissive.option(pathread, length).value.reset()")
|
||||
raises(IndexError, "api.forcepermissive.option(pathread, length).owner.get()")
|
||||
raises(IndexError, "api.forcepermissive.option(pathread, length).owner.isdefault()")
|
||||
raises(IndexError, "api.forcepermissive.option(pathread, length).property.get()")
|
||||
raises(IndexError, "api.forcepermissive.option(pathread, length).owner.set('new_user')")
|
||||
raises(IndexError, "api.forcepermissive.option(pathread, length).property.set(('prop',))")
|
||||
raises(SlaveError, "api.forcepermissive.option(pathread, length).value.get()")
|
||||
raises(SlaveError, "api.forcepermissive.option(pathread, length).value.set(value)")
|
||||
raises(SlaveError, "api.forcepermissive.option(pathread, length).value.reset()")
|
||||
raises(SlaveError, "api.forcepermissive.option(pathread, length).owner.get()")
|
||||
raises(SlaveError, "api.forcepermissive.option(pathread, length).owner.isdefault()")
|
||||
raises(SlaveError, "api.forcepermissive.option(pathread, length).property.get()")
|
||||
raises(SlaveError, "api.forcepermissive.option(pathread, length).owner.set('new_user')")
|
||||
raises(SlaveError, "api.forcepermissive.option(pathread, length).property.add('prop')")
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -488,12 +471,12 @@ def autocheck_reset_value(api, pathread, pathwrite, confread, confwrite, **kwarg
|
|||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
api.config(confwrite).option(pathwrite).value.reset()
|
||||
#else:
|
||||
# raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite).value.reset()")
|
||||
#FIXME raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite).value.reset()")
|
||||
else:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
api.config(confwrite).option(pathwrite, 0).value.reset()
|
||||
#else:
|
||||
# raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite, 0).value.reset()")
|
||||
#FIXME raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite, 0).value.reset()")
|
||||
|
||||
# get value after reset value without permissive
|
||||
def do(conf):
|
||||
|
@ -606,7 +589,6 @@ def autocheck_reset_value_permissive(api, pathread, pathwrite, confread, confwri
|
|||
# check if is a multi, a master or a slave
|
||||
isslave = api.unrestraint.option(pathread).option.isslave()
|
||||
_set_value(api, pathwrite, confwrite, **kwargs)
|
||||
|
||||
# reset value with permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
|
@ -618,14 +600,14 @@ def autocheck_reset_value_permissive(api, pathread, pathwrite, confread, confwri
|
|||
api.forcepermissive.config(confwrite).option(pathwrite).value.reset()
|
||||
else:
|
||||
api.forcepermissive.option(pathwrite, 1).value.reset()
|
||||
#else:
|
||||
#FIXME else:
|
||||
# if not isslave:
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.config(confwrite).option(pathwrite).value.reset()")
|
||||
# else:
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.option(pathwrite, 1).value.reset()")
|
||||
_autocheck_default_value(api, pathread, confread, **kwargs)
|
||||
if confread != confwrite:
|
||||
_autocheck_default_value(api, pathread, confwrite, **kwargs)
|
||||
_autocheck_default_value(api, pathwrite, confwrite, **kwargs)
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -636,16 +618,10 @@ def autocheck_display(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
|||
return
|
||||
make_dict = kwargs['make_dict']
|
||||
make_dict_value = kwargs['make_dict_value']
|
||||
#print('--------')
|
||||
#print(make_dict)
|
||||
#print(api.config(confread).config.make_dict())
|
||||
assert api.config(confread).option.make_dict() == make_dict
|
||||
if confread != confwrite:
|
||||
assert(api.config(confwrite).option.make_dict()) == make_dict
|
||||
_set_value(api, pathwrite, confwrite, **kwargs)
|
||||
#print('--')
|
||||
#print(make_dict_value)
|
||||
#print(api.config(confread).config.make_dict())
|
||||
assert api.config(confread).option.make_dict() == make_dict_value
|
||||
if confread != confwrite:
|
||||
assert(api.config(confwrite).option.make_dict()) == make_dict_value
|
||||
|
@ -666,29 +642,52 @@ def _getproperties(multi, isslave, kwargs):
|
|||
return default_props, frozenset(properties)
|
||||
|
||||
|
||||
def _check_default_properties(api, pathread, conf, kwargs, props_permissive, props):
|
||||
def _check_properties(api, pathread, conf, kwargs, props_permissive, props):
|
||||
if not api.unrestraint.option(pathread).option.isslave():
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert set(api.config(conf).option(pathread).property.get()) == set(props_permissive)
|
||||
assert set(api.config(conf).forcepermissive.option(pathread).property.get()) == set(props_permissive)
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
#raises(PropertiesOptionError, "api.config(conf).option(pathread).property.get()")
|
||||
assert set(api.config(conf).option(pathread).property.get()) == set(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):
|
||||
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:
|
||||
# raises(PropertiesOptionError, "api.config(conf).option(pathread).property.get()")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).property.get()")
|
||||
#raises(APIError, "api.unrestraint.option(pathread).property.get()")
|
||||
else:
|
||||
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:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert set(api.config(conf).option(pathread, 0).property.get()) == set(props_permissive)
|
||||
assert set(api.config(conf).option(pathread, 0).property.get()) == set(props)
|
||||
#
|
||||
assert set(api.config(conf).option(pathread, 1).property.get()) == set(props_permissive)
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).property.get()")
|
||||
assert set(api.forcepermissive.config(conf).option(pathread, 0).property.get()) == set(props)
|
||||
assert set(api.forcepermissive.config(conf).option(pathread, 1).property.get()) == set(props)
|
||||
assert set(api.config(conf).option(pathread, 1).property.get()) == set(props)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread, 0).property.get()")
|
||||
raises(APIError, "api.unrestraint.option(pathread, 0).property.get()")
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread, 0).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):
|
||||
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, 1).property.get()) == set(props_permissive)
|
||||
assert set(api.forcepermissive.config(conf).option(pathread, 1).property.get()) == set(props)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread, 0).property.get()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread, 0).property.get()")
|
||||
#
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread, 1).property.get()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread, 1).property.get()")
|
||||
assert set(api.unrestraint.config(conf).option(pathread, 0).property.get()) == set(props_permissive)
|
||||
assert set(api.unrestraint.config(conf).option(pathread, 0).property.get()) == set(props)
|
||||
#
|
||||
assert set(api.unrestraint.config(conf).option(pathread, 1).property.get()) == set(props_permissive)
|
||||
assert set(api.unrestraint.config(conf).option(pathread, 1).property.get()) == set(props)
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -701,21 +700,17 @@ def autocheck_property(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
|||
|
||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||
|
||||
_check_default_properties(api, pathread, confread, kwargs, default_props, default_props)
|
||||
_check_default_properties(api, pathread, confwrite, kwargs, default_props, default_props)
|
||||
_check_properties(api, pathread, confread, kwargs, default_props, default_props)
|
||||
if confread != confwrite:
|
||||
_check_properties(api, pathread, confwrite, kwargs, default_props, default_props)
|
||||
|
||||
# set properties without permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
for prop in properties:
|
||||
api.config(confwrite).option(pathwrite).property.add(prop)
|
||||
#else:
|
||||
# raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite).property.set(properties)")
|
||||
|
||||
_check_default_properties(api, pathread, confread, kwargs, properties, default_props)
|
||||
for prop in properties:
|
||||
api.config(confwrite).option(pathwrite).property.add(prop)
|
||||
_check_properties(api, pathread, confread, kwargs, properties, properties)
|
||||
if confread != confwrite:
|
||||
_check_default_properties(api, pathread, confwrite, kwargs, properties, default_props)
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
raises(ConfigError, "api.config(confread).option(pathread).property.set(properties)")
|
||||
_check_properties(api, pathread, confwrite, kwargs, properties, properties)
|
||||
|
||||
|
||||
|
||||
def _property_permissive(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
|
@ -736,28 +731,19 @@ def _property_permissive(api, pathread, pathwrite, confread, confwrite, **kwargs
|
|||
default_props.extend(extra_properties)
|
||||
default_props, properties = _getproperties(multi, isslave, kwargs)
|
||||
|
||||
_check_default_properties(api, pathread, confwrite, kwargs, default_props, default_props)
|
||||
_check_properties(api, pathread, confwrite, kwargs, default_props, default_props)
|
||||
if confwrite != confread:
|
||||
_check_default_properties(api, pathread, confread, kwargs, default_props, default_props)
|
||||
_check_properties(api, pathread, confread, kwargs, default_props, default_props)
|
||||
|
||||
# set properties with permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
for prop in properties:
|
||||
api.config(confwrite).option(pathwrite).property.add(prop)
|
||||
api.forcepermissive.config(confwrite).option(pathwrite).property.add(prop)
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
for prop in properties:
|
||||
#raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite).property.add(prop)")
|
||||
api.forcepermissive.config(confwrite).option(pathwrite).property.add(prop)
|
||||
#else:
|
||||
# raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite).property.set(properties)")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.config(confwrite).option(pathwrite).property.set(properties)")
|
||||
for prop in properties:
|
||||
api.config(confwrite).option(pathwrite).property.add(prop)
|
||||
api.forcepermissive.config(confwrite).option(pathwrite).property.add(prop)
|
||||
api.unrestraint.config(confwrite).option(pathwrite).property.add(prop)
|
||||
|
||||
_check_default_properties(api, pathread, confwrite, kwargs, properties, properties)
|
||||
_check_properties(api, pathread, confwrite, kwargs, properties, properties)
|
||||
if confwrite != confread:
|
||||
_check_default_properties(api, pathread, confread, kwargs, properties, properties)
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
raises(ConfigError, "api.config(confread).option(pathwrite).property.set(properties)")
|
||||
_check_properties(api, pathread, confread, kwargs, properties, properties)
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -777,16 +763,11 @@ def autocheck_reset_property(api, pathread, pathwrite, confread, confwrite, **kw
|
|||
_property_permissive(api, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||
|
||||
# reset properties without permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
api.config(confwrite).option(pathwrite).property.reset()
|
||||
#else:
|
||||
# raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite).property.reset()")
|
||||
api.config(confwrite).option(pathwrite).property.reset()
|
||||
|
||||
_check_default_properties(api, pathread, confread, kwargs, default_props, properties)
|
||||
_check_properties(api, pathread, confread, kwargs, default_props, default_props)
|
||||
if confread != confwrite:
|
||||
_check_default_properties(api, pathread, confwrite, kwargs, default_props, properties)
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
raises(ConfigError, "api.config(confread).option(pathread).property.reset()")
|
||||
_check_properties(api, pathread, confwrite, kwargs, default_props, default_props)
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -798,25 +779,19 @@ def autocheck_reset_property_permissive(api, pathread, pathwrite, confread, conf
|
|||
|
||||
_property_permissive(api, pathread, pathwrite, confread, confwrite, **kwargs)
|
||||
|
||||
# reset properties with permissive
|
||||
raises(APIError, "api.unrestraint.option(pathwrite).property.set(properties)")
|
||||
#raises(APIError, "api.unrestraint.option(pathwrite).property.reset()")
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
for prop in properties:
|
||||
api.forcepermissive.option(pathwrite).property.add(prop)
|
||||
api.forcepermissive.option(pathwrite).property.reset()
|
||||
elif kwargs.get('permissive', False):
|
||||
api.forcepermissive.option(pathwrite).property.reset()
|
||||
for prop in properties:
|
||||
api.forcepermissive.option(pathwrite).property.add(prop)
|
||||
api.forcepermissive.option(pathwrite).property.reset()
|
||||
|
||||
_check_default_properties(api, pathread, confwrite, kwargs, default_props, default_props)
|
||||
_check_properties(api, pathread, confwrite, kwargs, default_props, default_props)
|
||||
if confread != confwrite:
|
||||
_check_default_properties(api, pathread, confread, kwargs, default_props, default_props)
|
||||
_check_properties(api, pathread, confread, kwargs, default_props, default_props)
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_context_owner(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
owner = api.owner.get()
|
||||
assert owner == OWNER
|
||||
assert owner == kwargs['owner']
|
||||
|
||||
|
||||
def _check_owner(api, pathread, conf, kwargs, owner, permissive_owner):
|
||||
|
@ -826,11 +801,11 @@ def _check_owner(api, pathread, conf, kwargs, owner, permissive_owner):
|
|||
assert api.config(conf).option(pathread).owner.get() == owner
|
||||
assert api.forcepermissive.config(conf).option(pathread).owner.get() == owner
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
#raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.get()")
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.get()")
|
||||
assert api.forcepermissive.config(conf).option(pathread).owner.get() == permissive_owner
|
||||
#else:
|
||||
# raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.get()")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).owner.get()")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.config(conf).option(pathread).owner.get()")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).owner.get()")
|
||||
else:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert api.config(conf).option(pathread, 0).owner.get() == 'default'
|
||||
|
@ -852,9 +827,9 @@ def autocheck_owner_with_value(api, pathread, pathwrite, confread, confwrite, **
|
|||
"""value is now changed, check owner in this case
|
||||
"""
|
||||
_set_value(api, pathwrite, confwrite, **kwargs)
|
||||
_check_owner(api, pathread, confwrite, kwargs, OWNER, OWNER)
|
||||
_check_owner(api, pathread, confwrite, kwargs, kwargs['owner'], kwargs['owner'])
|
||||
if confread != confwrite:
|
||||
_check_owner(api, pathread, confread, kwargs, owners.meta, owners.meta)
|
||||
_check_owner(api, pathread, confread, kwargs, kwargs['owner'], kwargs['owner'])
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -868,7 +843,7 @@ def autocheck_default_owner_with_value(api, pathread, pathwrite, confread, confw
|
|||
assert api.config(confwrite).option(pathread).owner.isdefault() is False
|
||||
if confwrite != confread:
|
||||
assert api.config(confread).option(pathread).owner.isdefault() is False
|
||||
#else:
|
||||
#FIXME else:
|
||||
# raises(PropertiesOptionError, "api.config(confwrite).option(pathread).owner.isdefault()")
|
||||
# raises(PropertiesOptionError, "api.config(confread).option(pathread).owner.isdefault()")
|
||||
else:
|
||||
|
@ -878,9 +853,9 @@ def autocheck_default_owner_with_value(api, pathread, pathwrite, confread, confw
|
|||
if confwrite != confread:
|
||||
assert api.config(confread).option(pathread, 0).owner.isdefault() is True
|
||||
assert api.config(confread).option(pathread, 1).owner.isdefault() is False
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.config(confwrite).option(pathread, 0).owner.isdefault()")
|
||||
raises(PropertiesOptionError, "api.config(confread).option(pathread, 0).owner.isdefault()")
|
||||
#FIXME else:
|
||||
# raises(PropertiesOptionError, "api.config(confwrite).option(pathread, 0).owner.isdefault()")
|
||||
# raises(PropertiesOptionError, "api.config(confread).option(pathread, 0).owner.isdefault()")
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -898,7 +873,7 @@ def autocheck_default_owner_with_value_permissive(api, pathread, pathwrite, conf
|
|||
else:
|
||||
assert api.forcepermissive.config(conf).option(pathread, 0).owner.isdefault() is True
|
||||
assert api.forcepermissive.config(conf).option(pathread, 1).owner.isdefault() is False
|
||||
#else:
|
||||
#FIXME else:
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.config(conf).option(pathread).owner.isdefault()")
|
||||
do(confwrite)
|
||||
if confwrite != confread:
|
||||
|
@ -929,17 +904,17 @@ def autocheck_set_owner(api, pathread, pathwrite, confread, confwrite, **kwargs)
|
|||
raises(ConfigError, "api.config(confwrite).option(pathwrite).owner.set('default')")
|
||||
raises(ConfigError, "api.config(confwrite).option(pathwrite).owner.set('forced')")
|
||||
raises(ConfigError, "api.config(confwrite).option(pathwrite).owner.set('meta')")
|
||||
#else:
|
||||
#FIXME else:
|
||||
# raises(PropertiesOptionError, "api.config(confwrite).option(pathwrite).owner.set('new_user')")
|
||||
else:
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
api.option(pathwrite, 1).owner.set('new_user')
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.option(pathwrite, 1).owner.set('new_user')")
|
||||
#FIXME else:
|
||||
# raises(PropertiesOptionError, "api.option(pathwrite, 1).owner.set('new_user')")
|
||||
|
||||
_check_owner(api, pathread, confwrite, kwargs, owners.new_user, OWNER)
|
||||
_check_owner(api, pathread, confwrite, kwargs, owners.new_user, kwargs['owner'])
|
||||
if confwrite != confread:
|
||||
_check_owner(api, pathread, confread, kwargs, owners.meta, owners.meta)
|
||||
_check_owner(api, pathread, confread, kwargs, owners.new_user, owners.meta)
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -954,7 +929,7 @@ def autocheck_set_owner_permissive(api, pathread, pathwrite, confread, confwrite
|
|||
api.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user1')
|
||||
else:
|
||||
api.forcepermissive.option(pathwrite, 1).owner.set('new_user1')
|
||||
#else:
|
||||
#FIXME else:
|
||||
# if not isslave:
|
||||
# raises(PropertiesOptionError,
|
||||
# "api.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user1')")
|
||||
|
@ -964,40 +939,40 @@ def autocheck_set_owner_permissive(api, pathread, pathwrite, confread, confwrite
|
|||
|
||||
_check_owner(api, pathread, confwrite, kwargs, 'new_user1', 'new_user1')
|
||||
if confwrite != confread:
|
||||
_check_owner(api, pathread, confread, kwargs, owners.meta, owners.meta)
|
||||
_check_owner(api, pathread, confread, kwargs, 'new_user1', 'new_user1')
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_option(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
expected_name = pathread.split('.')[-1]
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
current_name = api.option(pathread).option.name
|
||||
assert current_name == api.forcepermissive.option(pathread).option.name
|
||||
assert current_name == api.unrestraint.option(pathread).option.name
|
||||
doc = api.option(pathread).option.doc()
|
||||
assert doc == api.forcepermissive.option(pathread).option.doc()
|
||||
assert doc == api.unrestraint.option(pathread).option.doc()
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
#raises(PropertiesOptionError, "api.option(pathread).option.name")
|
||||
current_name = api.forcepermissive.option(pathread).option.name
|
||||
assert current_name == api.unrestraint.option(pathread).option.name
|
||||
#raises(PropertiesOptionError, "api.option(pathread).option.doc()")
|
||||
doc = api.forcepermissive.option(pathread).option.doc()
|
||||
assert doc == api.unrestraint.option(pathread).option.doc()
|
||||
else:
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.name")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.name")
|
||||
current_name = api.unrestraint.option(pathread).option.name
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.doc()")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.doc()")
|
||||
doc = api.unrestraint.option(pathread).option.doc()
|
||||
assert current_name == expected_name
|
||||
if expected_name.endswith('val1') or expected_name.endswith('val2'):
|
||||
expected_name = expected_name[:-4]
|
||||
if kwargs['symlink']:
|
||||
assert doc == "{}'s option link".format(expected_name)
|
||||
else:
|
||||
assert doc == "{}'s option".format(expected_name)
|
||||
#FIXME @autocheck
|
||||
#def autocheck_option(api, pathread, pathwrite, confread, confwrite, **kwargs):
|
||||
# expected_name = pathread.split('.')[-1]
|
||||
# if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
# current_name = api.option(pathread).option.name
|
||||
# assert current_name == api.forcepermissive.option(pathread).option.name
|
||||
# assert current_name == api.unrestraint.option(pathread).option.name
|
||||
# doc = api.option(pathread).option.doc()
|
||||
# assert doc == api.forcepermissive.option(pathread).option.doc()
|
||||
# assert doc == api.unrestraint.option(pathread).option.doc()
|
||||
# elif not kwargs.get('propertyerror', False):
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.name")
|
||||
# current_name = api.forcepermissive.option(pathread).option.name
|
||||
# assert current_name == api.unrestraint.option(pathread).option.name
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.doc()")
|
||||
# doc = api.forcepermissive.option(pathread).option.doc()
|
||||
# assert doc == api.unrestraint.option(pathread).option.doc()
|
||||
# else:
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.name")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.name")
|
||||
# current_name = api.unrestraint.option(pathread).option.name
|
||||
# raises(PropertiesOptionError, "api.option(pathread).option.doc()")
|
||||
# raises(PropertiesOptionError, "api.forcepermissive.option(pathread).option.doc()")
|
||||
# doc = api.unrestraint.option(pathread).option.doc()
|
||||
# assert current_name == expected_name
|
||||
# if expected_name.endswith('val1') or expected_name.endswith('val2'):
|
||||
# expected_name = expected_name[:-4]
|
||||
# if kwargs['symlink']:
|
||||
# assert doc == "{}'s option link".format(expected_name)
|
||||
# else:
|
||||
# assert doc == "{}'s option".format(expected_name)
|
||||
|
||||
|
||||
@autocheck
|
||||
|
@ -1336,6 +1311,12 @@ def check_all(cfg, paths, path, meta, multi, default, default_multi, require, co
|
|||
weakrefs.append(weakref.ref(cfg))
|
||||
api = getapi(ncfg)
|
||||
ckwargs = copy(kwargs)
|
||||
if meta:
|
||||
api.owner.set('meta')
|
||||
ckwargs['owner'] = owners.meta
|
||||
else:
|
||||
ckwargs['owner'] = OWNER
|
||||
|
||||
if api.unrestraint.option(path).option.isslave():
|
||||
dirname = path.rsplit('.', 1)[0]
|
||||
master_path = dirname + '.first'
|
||||
|
@ -1469,6 +1450,8 @@ def make_conf(options, meta, multi, default, default_multi, require, consistency
|
|||
if in_master and symlink:
|
||||
return None, None, None
|
||||
if option_infos is not None:
|
||||
if require:
|
||||
return None, None, None
|
||||
for prop in PROPERTIES:
|
||||
if option_infos.get(prop, False) is True:
|
||||
if not require:
|
||||
|
@ -1537,7 +1520,7 @@ def make_conf(options, meta, multi, default, default_multi, require, consistency
|
|||
gopt = goptions[1]
|
||||
else:
|
||||
gopt = goptions[0]
|
||||
obj.impl_add_consistency('not_equal', gopt, warnings_only=True)
|
||||
obj.impl_add_consistency('not_equal', gopt, warnings_only=True, transitive=False)
|
||||
return obj, objcall, sobj
|
||||
|
||||
def make_optiondescriptions(path, collected):
|
||||
|
@ -1643,63 +1626,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)]),
|
||||
]
|
||||
|
||||
|
||||
|
@ -1734,16 +1717,27 @@ def test_options(paths):
|
|||
return kwargs
|
||||
|
||||
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):
|
||||
|
||||
# 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,):
|
||||
if callback and default_multi:
|
||||
continue
|
||||
for default in (False, True):
|
||||
for multi in (False, True, submulti):
|
||||
for default in (False,):
|
||||
for multi in (False,):
|
||||
if multi is submulti and default:
|
||||
continue
|
||||
if multi is submulti and consistency:
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# ____________________________________________________________
|
||||
from inspect import ismethod, getdoc
|
||||
from .error import APIError, PropertiesOptionError, ConfigError
|
||||
from .error import APIError, ConfigError, SlaveError
|
||||
from .i18n import _
|
||||
from .setting import ConfigBag, owners, undefined
|
||||
from .option import ChoiceOption
|
||||
|
@ -90,6 +90,12 @@ class CommonTiramisu(object):
|
|||
self.config_bag,
|
||||
self.subconfig)
|
||||
self.config_bag.option = option
|
||||
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 "{}" '
|
||||
'for option "{}"').format(self.index,
|
||||
self.subconfig.cfgimpl_get_length(),
|
||||
option.impl_get_display_name()))
|
||||
if not self.allow_optiondescription and option.impl_is_optiondescription():
|
||||
raise APIError(_('option must not be an optiondescription'))
|
||||
return option
|
||||
|
@ -115,7 +121,7 @@ class CommonTiramisuOption(CommonTiramisu):
|
|||
self.subconfig = subconfig
|
||||
if self.slave_need_index:
|
||||
self._test_slave_index()
|
||||
if not self.allow_unrestraint:
|
||||
if not self.allow_unrestraint and self.config_bag.force_unrestraint:
|
||||
self._unrestraint_not_allowed(self.config_bag.force_unrestraint)
|
||||
|
||||
def _test_slave_index(self):
|
||||
|
@ -127,9 +133,8 @@ class CommonTiramisuOption(CommonTiramisu):
|
|||
raise APIError('index must be set only with a slave option')
|
||||
|
||||
def _unrestraint_not_allowed(self, force_unrestraint):
|
||||
if force_unrestraint:
|
||||
name = self.__class__.__name__[14:].lower()
|
||||
raise APIError(_('{} cannot be unrestraint').format(name))
|
||||
name = self.__class__.__name__[14:].lower()
|
||||
raise APIError(_('{} cannot be unrestraint').format(name))
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name == 'help':
|
||||
|
@ -138,7 +143,7 @@ class CommonTiramisuOption(CommonTiramisu):
|
|||
if not hasattr(CommonTiramisuOption, name):
|
||||
raise APIError(_('unknown method {}').format(name))
|
||||
else:
|
||||
super(CommonTiramisuOption, self).__getattribute__(name)
|
||||
super().__getattribute__(name)
|
||||
|
||||
def _help(self):
|
||||
txt = []
|
||||
|
@ -240,7 +245,6 @@ class TiramisuOptionOption(CommonTiramisuOption):
|
|||
|
||||
class TiramisuOptionOwner(CommonTiramisuOption):
|
||||
"""manager option's owner"""
|
||||
allow_unrestraint = True
|
||||
|
||||
def __init__(self,
|
||||
name,
|
||||
|
@ -249,17 +253,17 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
|||
subconfig,
|
||||
config_bag):
|
||||
|
||||
super(TiramisuOptionOwner, self).__init__(name,
|
||||
path,
|
||||
index,
|
||||
subconfig,
|
||||
config_bag)
|
||||
super().__init__(name,
|
||||
path,
|
||||
index,
|
||||
subconfig,
|
||||
config_bag)
|
||||
self.values = self.config_bag.config.cfgimpl_get_values()
|
||||
|
||||
@count
|
||||
def get(self):
|
||||
"""get owner for a specified option"""
|
||||
self._get_option()
|
||||
option = self._get_option()
|
||||
return self.values.getowner(self.path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
|
@ -302,11 +306,11 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
index,
|
||||
subconfig,
|
||||
config_bag):
|
||||
super(TiramisuOptionProperty, self).__init__(name,
|
||||
path,
|
||||
index,
|
||||
subconfig,
|
||||
config_bag)
|
||||
super().__init__(name,
|
||||
path,
|
||||
index,
|
||||
subconfig,
|
||||
config_bag)
|
||||
self.settings = config_bag.config.cfgimpl_get_settings()
|
||||
|
||||
@count
|
||||
|
@ -358,11 +362,11 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
|||
index,
|
||||
subconfig,
|
||||
config_bag):
|
||||
super(TiramisuOptionPermissive, self).__init__(name,
|
||||
path,
|
||||
index,
|
||||
subconfig,
|
||||
config_bag)
|
||||
super().__init__(name,
|
||||
path,
|
||||
index,
|
||||
subconfig,
|
||||
config_bag)
|
||||
self.settings = config_bag.config.cfgimpl_get_settings()
|
||||
|
||||
@count
|
||||
|
@ -469,6 +473,10 @@ class TiramisuOptionValue(CommonTiramisuOption):
|
|||
def _len(self):
|
||||
self._get_option()
|
||||
subconfig_path = self.path.rsplit('.', 1)[0]
|
||||
if self.config_bag.setting_properties is not None:
|
||||
self.config_bag.config.cfgimpl_get_settings().validate_properties(self.path,
|
||||
self.index,
|
||||
self.config_bag)
|
||||
config_bag = self.config_bag.copy('nooption')
|
||||
subconfig = config_bag.config.getattr(subconfig_path,
|
||||
None,
|
||||
|
@ -726,9 +734,12 @@ class TiramisuContextOption(TiramisuContext):
|
|||
|
||||
@count
|
||||
def get(self, path):
|
||||
config_bag = self.config_bag.copy()
|
||||
config_bag.validate = False
|
||||
config_bag.force_unrestraint = True
|
||||
config_bag.setting_properties = None
|
||||
return self.config_bag.config.unwrap_from_path(path,
|
||||
None,
|
||||
self.config_bag)
|
||||
config_bag)
|
||||
|
||||
@count
|
||||
def make_dict(self,
|
||||
|
@ -782,8 +793,6 @@ class TiramisuDispatcherOption(TiramisuContextOption):
|
|||
return self
|
||||
config_bag = self.config_bag.copy()
|
||||
validate = not config_bag.force_unrestraint
|
||||
#config_bag.validate = validate
|
||||
#config_bag.validate_properties = validate
|
||||
if not validate:
|
||||
config_bag.setting_properties = None
|
||||
subconfig, name = config_bag.config.cfgimpl_get_home_by_path(path,
|
||||
|
|
|
@ -570,7 +570,6 @@ class SubConfig(object):
|
|||
if config_bag.validate_properties:
|
||||
try:
|
||||
self.unwrap_from_path(path,
|
||||
None,
|
||||
config_bag)
|
||||
self.cfgimpl_get_settings().validate_properties(path,
|
||||
None,
|
||||
|
@ -662,7 +661,6 @@ class SubConfig(object):
|
|||
config_bag=config_bag):
|
||||
path = '.'.join(path.split('.')[:-1])
|
||||
opt = context.unwrap_from_path(path,
|
||||
None,
|
||||
config_bag)
|
||||
sconfig_bag = config_bag.copy('nooption')
|
||||
sconfig_bag.option = opt
|
||||
|
@ -779,7 +777,6 @@ class _CommonConfig(SubConfig):
|
|||
|
||||
def unwrap_from_path(self,
|
||||
path,
|
||||
index,
|
||||
config_bag):
|
||||
"""convenience method to extract and Option() object from the Config()
|
||||
and it is **fast**: finds the option directly in the appropriate
|
||||
|
@ -805,17 +802,6 @@ class _CommonConfig(SubConfig):
|
|||
else:
|
||||
true_path = path
|
||||
config_bag.option = option
|
||||
#if not option.impl_is_optiondescription() and index is None and \
|
||||
# config_bag.option.impl_is_master_slaves('slave'):
|
||||
# subpath = self._get_subpath(true_path)
|
||||
# self.cfgimpl_get_settings().validate_properties(subpath,
|
||||
# index,
|
||||
# config_bag)
|
||||
# return option
|
||||
#self.getattr(path,
|
||||
# index,
|
||||
# config_bag,
|
||||
# returns_option=True)
|
||||
return option
|
||||
|
||||
def cfgimpl_get_path(self, dyn=True):
|
||||
|
|
|
@ -326,7 +326,9 @@ class Values(object):
|
|||
|
||||
context = self._getcontext()
|
||||
owner = context.cfgimpl_get_settings().getowner()
|
||||
if 'validator' in config_bag.setting_properties and config_bag.validate:
|
||||
if config_bag.setting_properties is not None and \
|
||||
'validator' in config_bag.setting_properties and \
|
||||
config_bag.validate:
|
||||
if index is not None or config_bag.option._has_consistencies(context):
|
||||
# set value to a fake config when option has dependency
|
||||
# validation will be complet in this case (consistency, ...)
|
||||
|
@ -490,11 +492,16 @@ class Values(object):
|
|||
config_bag.option = opt
|
||||
path = opt.impl_getpath(context)
|
||||
self_properties = config_bag.properties
|
||||
settings = context.cfgimpl_get_settings()
|
||||
if self_properties is None:
|
||||
self_properties = context.cfgimpl_get_settings().getproperties(path,
|
||||
index,
|
||||
config_bag)
|
||||
self_properties = settings.getproperties(path,
|
||||
index,
|
||||
config_bag)
|
||||
config_bag.properties = self_properties
|
||||
if config_bag.setting_properties is not None:
|
||||
settings.validate_properties(path,
|
||||
index,
|
||||
config_bag)
|
||||
if 'frozen' in self_properties and 'force_default_on_freeze' in self_properties:
|
||||
return owners.default
|
||||
if only_default:
|
||||
|
|
Loading…
Reference in New Issue