some corrections

This commit is contained in:
2018-03-31 21:06:19 +02:00
parent eba178cdee
commit 790115c919
4 changed files with 284 additions and 288 deletions

View File

@ -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: