update test_auto (fixes #2)

This commit is contained in:
Emmanuel Garette 2019-03-02 19:30:21 +01:00
parent e786b4068d
commit d25edd7dd7
1 changed files with 356 additions and 238 deletions

View File

@ -83,30 +83,34 @@ def _autocheck_default_value(cfg, path, conf, **kwargs):
# test default value (should be empty) # test default value (should be empty)
# cannot test for follower (we cannot get all values for a follower) # cannot test for follower (we cannot get all values for a follower)
if conf is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
if not isfollower: if not isfollower:
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 cfg.config(conf).option(path).value.get() == empty_value assert cfg_.option(path).value.get() == empty_value
assert cfg.config(conf).forcepermissive.option(path).value.get() == empty_value assert cfg_.forcepermissive.option(path).value.get() == empty_value
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(path).value.get()") raises(PropertiesOptionError, "cfg_.option(path).value.get()")
assert cfg.config(conf).forcepermissive.option(path).value.get() == empty_value assert cfg_.forcepermissive.option(path).value.get() == empty_value
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(path).value.get()") raises(PropertiesOptionError, "cfg_.option(path).value.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(path).value.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(path).value.get()")
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 cfg.config(conf).option(path, 0).value.get() == empty_value assert cfg_.option(path, 0).value.get() == empty_value
assert cfg.config(conf).option(path, 1).value.get() == empty_value assert cfg_.option(path, 1).value.get() == empty_value
assert cfg.config(conf).forcepermissive.option(path, 0).value.get() == empty_value assert cfg_.forcepermissive.option(path, 0).value.get() == empty_value
assert cfg.config(conf).forcepermissive.option(path, 1).value.get() == empty_value assert cfg_.forcepermissive.option(path, 1).value.get() == empty_value
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(path, 0).value.get()") raises(PropertiesOptionError, "cfg_.option(path, 0).value.get()")
assert cfg.config(conf).forcepermissive.option(path, 0).value.get() == empty_value assert cfg_.forcepermissive.option(path, 0).value.get() == empty_value
assert cfg.config(conf).forcepermissive.option(path, 1).value.get() == empty_value assert cfg_.forcepermissive.option(path, 1).value.get() == empty_value
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(path, 0).value.get()") raises(PropertiesOptionError, "cfg_.option(path, 0).value.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(path, 0).value.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(path, 0).value.get()")
def _set_value(cfg, pathwrite, conf, **kwargs): def _set_value(cfg, pathwrite, conf, **kwargs):
@ -131,52 +135,56 @@ def _set_value(cfg, pathwrite, conf, **kwargs):
# for follower should have an index and good length # for follower should have an index and good length
# for leader must append, not set # for leader must append, not set
if conf is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
if isleader: if isleader:
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
raises(APIError, "cfg.config(conf).option(pathwrite, 0).value.set(first_value[0])") raises(APIError, "cfg_.option(pathwrite, 0).value.set(first_value[0])")
if not set_permissive: if not set_permissive:
cfg.config(conf).option(pathwrite).value.set([first_value[0]]) cfg_.option(pathwrite).value.set([first_value[0]])
else: else:
cfg.config(conf).forcepermissive.option(pathwrite).value.set([first_value[0]]) cfg_.forcepermissive.option(pathwrite).value.set([first_value[0]])
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite).value.set([first_value[0]])") raises(PropertiesOptionError, "cfg_.option(pathwrite).value.set([first_value[0]])")
if set_permissive: if set_permissive:
cfg.config(conf).forcepermissive.option(pathwrite).value.set([first_value[0]]) cfg_.forcepermissive.option(pathwrite).value.set([first_value[0]])
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite).value.set([first_value[0]])") raises(PropertiesOptionError, "cfg_.option(pathwrite).value.set([first_value[0]])")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathwrite).value.set([first_value[0]])") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathwrite).value.set([first_value[0]])")
if len(first_value) > 1: if len(first_value) > 1:
raises(APIError, "cfg.config(conf).unrestraint.option(pathwrite).value.set(first_value[1])") raises(APIError, "cfg_.unrestraint.option(pathwrite).value.set(first_value[1])")
elif isfollower: elif isfollower:
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
if not set_permissive: if not set_permissive:
cfg.config(conf).option(pathwrite, 1).value.set(second_value) cfg_.option(pathwrite, 1).value.set(second_value)
else: else:
cfg.config(conf).forcepermissive.option(pathwrite, 1).value.set(second_value) cfg_.forcepermissive.option(pathwrite, 1).value.set(second_value)
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite, 1).value.set(second_value)") raises(PropertiesOptionError, "cfg_.option(pathwrite, 1).value.set(second_value)")
if set_permissive: if set_permissive:
cfg.config(conf).forcepermissive.option(pathwrite, 1).value.set(second_value) cfg_.forcepermissive.option(pathwrite, 1).value.set(second_value)
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite, 1).value.set(second_value)") raises(PropertiesOptionError, "cfg_.option(pathwrite, 1).value.set(second_value)")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathwrite, 1).value.set(second_value)") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathwrite, 1).value.set(second_value)")
raises(APIError, "cfg.config(conf).unrestraint.option(pathwrite).value.set([second_value, second_value])") raises(APIError, "cfg_.unrestraint.option(pathwrite).value.set([second_value, second_value])")
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):
if not set_permissive: if not set_permissive:
cfg.config(conf).option(pathwrite).value.set(first_value) cfg_.option(pathwrite).value.set(first_value)
else: else:
cfg.config(conf).forcepermissive.option(pathwrite).value.set(first_value) cfg_.forcepermissive.option(pathwrite).value.set(first_value)
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite).value.set(first_value)") raises(PropertiesOptionError, "cfg_.option(pathwrite).value.set(first_value)")
if set_permissive: if set_permissive:
cfg.config(conf).forcepermissive.option(pathwrite).value.set(first_value) cfg_.forcepermissive.option(pathwrite).value.set(first_value)
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite).value.set(first_value)") raises(PropertiesOptionError, "cfg_.option(pathwrite).value.set(first_value)")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathwrite).value.set(first_value)") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathwrite).value.set(first_value)")
#FIXME raises(APIError, "cfg.config(conf).unrestraint.option(pathwrite).value.set(first_value)") #FIXME raises(APIError, "cfg_.unrestraint.option(pathwrite).value.set(first_value)")
def _getproperties(multi, isfollower, kwargs): def _getproperties(multi, isfollower, kwargs):
@ -195,37 +203,41 @@ def _getproperties(multi, isfollower, kwargs):
def _check_properties(cfg, mcfg, pathread, conf, kwargs, props_permissive, props): def _check_properties(cfg, mcfg, pathread, conf, kwargs, props_permissive, props):
if conf is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
if not cfg.unrestraint.option(pathread).option.isfollower(): if not cfg.unrestraint.option(pathread).option.isfollower():
if not kwargs.get('permissive_od', False): if not kwargs.get('permissive_od', False):
assert set(cfg.config(conf).option(pathread).property.get()) == set(props_permissive) assert set(cfg_.option(pathread).property.get()) == set(props_permissive)
assert set(cfg.config(conf).option(pathread).property.get()) == set(props) assert set(cfg_.option(pathread).property.get()) == set(props)
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).property.get()") raises(PropertiesOptionError, "cfg_.option(pathread).property.get()")
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).property.get()") raises(PropertiesOptionError, "cfg_.option(pathread).property.get()")
assert set(cfg.config(conf).forcepermissive.option(pathread).property.get()) == set(props_permissive) assert set(cfg_.forcepermissive.option(pathread).property.get()) == set(props_permissive)
assert set(cfg.config(conf).forcepermissive.option(pathread).property.get()) == set(props) assert set(cfg_.forcepermissive.option(pathread).property.get()) == set(props)
assert set(cfg.config(conf).unrestraint.option(pathread).property.get()) == set(props_permissive) assert set(cfg_.unrestraint.option(pathread).property.get()) == set(props_permissive)
assert set(cfg.config(conf).unrestraint.option(pathread).property.get()) == set(props) assert set(cfg_.unrestraint.option(pathread).property.get()) == set(props)
else: else:
if not kwargs.get('permissive_od', False): if not kwargs.get('permissive_od', False):
assert set(cfg.config(conf).option(pathread, 0).property.get()) == set(props_permissive) assert set(cfg_.option(pathread, 0).property.get()) == set(props_permissive)
assert set(cfg.config(conf).option(pathread, 0).property.get()) == set(props) assert set(cfg_.option(pathread, 0).property.get()) == set(props)
# #
assert set(cfg.config(conf).option(pathread, 1).property.get()) == set(props_permissive) assert set(cfg_.option(pathread, 1).property.get()) == set(props_permissive)
assert set(cfg.config(conf).option(pathread, 1).property.get()) == set(props) assert set(cfg_.option(pathread, 1).property.get()) == set(props)
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).property.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).property.get()")
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).property.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).property.get()")
# #
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 1).property.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 1).property.get()")
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 1).property.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 1).property.get()")
assert set(cfg.config(conf).forcepermissive.option(pathread, 0).property.get()) == set(props_permissive) assert set(cfg_.forcepermissive.option(pathread, 0).property.get()) == set(props_permissive)
assert set(cfg.config(conf).forcepermissive.option(pathread, 0).property.get()) == set(props) assert set(cfg_.forcepermissive.option(pathread, 0).property.get()) == set(props)
# #
assert set(cfg.config(conf).forcepermissive.option(pathread, 1).property.get()) == set(props_permissive) assert set(cfg_.forcepermissive.option(pathread, 1).property.get()) == set(props_permissive)
assert set(cfg.config(conf).forcepermissive.option(pathread, 1).property.get()) == set(props) assert set(cfg_.forcepermissive.option(pathread, 1).property.get()) == set(props)
assert set(cfg.config(conf).unrestraint.option(pathread, 1).property.get()) == set(props_permissive) assert set(cfg_.unrestraint.option(pathread, 1).property.get()) == set(props_permissive)
assert set(cfg.config(conf).unrestraint.option(pathread, 1).property.get()) == set(props) assert set(cfg_.unrestraint.option(pathread, 1).property.get()) == set(props)
def _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs): def _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
@ -253,12 +265,16 @@ def _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
# set properties with permissive # set properties with permissive
for prop in properties: for prop in properties:
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if confread is not None:
cfg.config(confread).option(pathwrite).property.add(prop) cfg_ = cfg.config(confread)
elif not kwargs.get('propertyerror', False):
cfg.config(confread).forcepermissive.option(pathwrite).property.add(prop)
else: else:
cfg.config(confread).unrestraint.option(pathwrite).property.add(prop) cfg_ = cfg
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
cfg_.option(pathwrite).property.add(prop)
elif not kwargs.get('propertyerror', False):
cfg_.forcepermissive.option(pathwrite).property.add(prop)
else:
cfg_.unrestraint.option(pathwrite).property.add(prop)
if confwrite == confread: if confwrite == confread:
_check_properties(cfg, mcfg, pathread, confwrite, kwargs, properties, properties) _check_properties(cfg, mcfg, pathread, confwrite, kwargs, properties, properties)
else: else:
@ -286,64 +302,72 @@ def _autocheck_get_value(cfg, pathread, conf, **kwargs):
second_value = SUBLIST_SECOND_VALUE[1] second_value = SUBLIST_SECOND_VALUE[1]
# get value after set value without permissive # get value after set value without permissive
if conf is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
if isfollower: if isfollower:
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 cfg.config(conf).option(pathread, 0).value.get() == empty_value assert cfg_.option(pathread, 0).value.get() == empty_value
assert cfg.config(conf).option(pathread, 1).value.get() == second_value assert cfg_.option(pathread, 1).value.get() == second_value
assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value
assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == second_value assert cfg_.forcepermissive.option(pathread, 1).value.get() == second_value
elif kwargs.get('permissive', False): elif kwargs.get('permissive', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).value.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).value.get()")
assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value
if set_permissive: if set_permissive:
assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == second_value assert cfg_.forcepermissive.option(pathread, 1).value.get() == second_value
else: else:
assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == empty_value assert cfg_.forcepermissive.option(pathread, 1).value.get() == empty_value
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).value.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).value.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread, 0).value.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread, 0).value.get()")
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 cfg.config(conf).option(pathread).value.get() == first_value assert cfg_.option(pathread).value.get() == first_value
assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value assert cfg_.forcepermissive.option(pathread).value.get() == first_value
elif kwargs.get('permissive', False): elif kwargs.get('permissive', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") raises(PropertiesOptionError, "cfg_.option(pathread).value.get()")
if set_permissive: if set_permissive:
assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value assert cfg_.forcepermissive.option(pathread).value.get() == first_value
else: else:
assert cfg.config(conf).forcepermissive.option(pathread).value.get() == empty_value assert cfg_.forcepermissive.option(pathread).value.get() == empty_value
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") raises(PropertiesOptionError, "cfg_.option(pathread).value.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).value.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).value.get()")
def _check_owner(cfg, pathread, conf, kwargs, owner, permissive_owner): def _check_owner(cfg, pathread, conf, kwargs, owner, permissive_owner):
isfollower = cfg.unrestraint.option(pathread).option.isfollower() isfollower = cfg.unrestraint.option(pathread).option.isfollower()
if conf is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
if not isfollower: if not isfollower:
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 cfg.config(conf).option(pathread).owner.get() == owner assert cfg_.option(pathread).owner.get() == owner
assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == owner assert cfg_.forcepermissive.option(pathread).owner.get() == owner
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread).owner.get()")
assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == permissive_owner assert cfg_.forcepermissive.option(pathread).owner.get() == permissive_owner
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread).owner.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).owner.get()")
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 cfg.config(conf).option(pathread, 0).owner.get() == 'default' assert cfg_.option(pathread, 0).owner.get() == 'default'
assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.get() == 'default' assert cfg_.forcepermissive.option(pathread, 0).owner.get() == 'default'
assert cfg.config(conf).option(pathread, 1).owner.get() == owner assert cfg_.option(pathread, 1).owner.get() == owner
assert cfg.config(conf).forcepermissive.option(pathread, 1).owner.get() == owner assert cfg_.forcepermissive.option(pathread, 1).owner.get() == owner
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.get()")
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 1).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 1).owner.get()")
assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.get() == 'default' assert cfg_.forcepermissive.option(pathread, 0).owner.get() == 'default'
assert cfg.config(conf).forcepermissive.option(pathread, 1).owner.get() == permissive_owner assert cfg_.forcepermissive.option(pathread, 1).owner.get() == permissive_owner
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread, 0).owner.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread, 0).owner.get()")
@autocheck @autocheck
@ -373,49 +397,53 @@ def autocheck_default_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite,
isfollower = cfg.unrestraint.option(pathread).option.isfollower() isfollower = cfg.unrestraint.option(pathread).option.isfollower()
# check if owner is a string "default" and 'isdefault' # check if owner is a string "default" and 'isdefault'
def do(conf): def do(conf):
if conf is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
if not isfollower: if not isfollower:
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 cfg.config(conf).option(pathread).owner.get() == 'default' assert cfg_.option(pathread).owner.get() == 'default'
assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == 'default' assert cfg_.forcepermissive.option(pathread).owner.get() == 'default'
# #
assert cfg.config(conf).option(pathread).owner.isdefault() assert cfg_.option(pathread).owner.isdefault()
assert cfg.config(conf).forcepermissive.option(pathread).owner.isdefault() assert cfg_.forcepermissive.option(pathread).owner.isdefault()
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread).owner.get()")
assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == 'default' assert cfg_.forcepermissive.option(pathread).owner.get() == 'default'
# #
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.isdefault()") raises(PropertiesOptionError, "cfg_.option(pathread).owner.isdefault()")
assert cfg.config(conf).forcepermissive.option(pathread).owner.isdefault() assert cfg_.forcepermissive.option(pathread).owner.isdefault()
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread).owner.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).owner.get()")
# #
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.isdefault()") raises(PropertiesOptionError, "cfg_.option(pathread).owner.isdefault()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.isdefault()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).owner.isdefault()")
# #
assert cfg.config(conf).unrestraint.option(pathread).owner.get() == 'default' assert cfg_.unrestraint.option(pathread).owner.get() == 'default'
assert cfg.config(conf).unrestraint.option(pathread).owner.isdefault() assert cfg_.unrestraint.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 cfg.config(conf).option(pathread, 0).owner.get() == 'default' assert cfg_.option(pathread, 0).owner.get() == 'default'
assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.get() == 'default' assert cfg_.forcepermissive.option(pathread, 0).owner.get() == 'default'
# #
assert cfg.config(conf).option(pathread, 0).owner.isdefault() assert cfg_.option(pathread, 0).owner.isdefault()
assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.isdefault() assert cfg_.forcepermissive.option(pathread, 0).owner.isdefault()
elif not kwargs.get('propertyerror', False): elif not kwargs.get('propertyerror', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.get()")
assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.get() == 'default' assert cfg_.forcepermissive.option(pathread, 0).owner.get() == 'default'
# #
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.isdefault()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.isdefault()")
assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.isdefault() assert cfg_.forcepermissive.option(pathread, 0).owner.isdefault()
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread, 0).owner.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread, 0).owner.get()")
# #
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.isdefault()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.isdefault()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread, 0).owner.isdefault()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread, 0).owner.isdefault()")
assert cfg.config(conf).unrestraint.option(pathread, 0).owner.get() == 'default' assert cfg_.unrestraint.option(pathread, 0).owner.get() == 'default'
assert cfg.config(conf).unrestraint.option(pathread, 0).owner.isdefault() assert cfg_.unrestraint.option(pathread, 0).owner.isdefault()
do(confread) do(confread)
if confread != confwrite: if confread != confwrite:
do(confwrite) do(confwrite)
@ -450,40 +478,44 @@ def autocheck_get_value_permissive(cfg, mcfg, pathread, pathwrite, confread, con
def do(conf): def do(conf):
# get value after set value without permissive # get value after set value without permissive
if conf is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
if isfollower: if isfollower:
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 cfg.config(conf).option(pathread, 0).value.get() == empty_value assert cfg_.option(pathread, 0).value.get() == empty_value
assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value
if submulti_: if submulti_:
assert cfg.config(conf).option(pathread, 1).value.get() == SUBLIST_SECOND_VALUE[1] assert cfg_.option(pathread, 1).value.get() == SUBLIST_SECOND_VALUE[1]
assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == SUBLIST_SECOND_VALUE[1] assert cfg_.forcepermissive.option(pathread, 1).value.get() == SUBLIST_SECOND_VALUE[1]
else: else:
assert cfg.config(conf).option(pathread, 1).value.get() == LIST_SECOND_VALUE[1] assert cfg_.option(pathread, 1).value.get() == LIST_SECOND_VALUE[1]
assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == LIST_SECOND_VALUE[1] assert cfg_.forcepermissive.option(pathread, 1).value.get() == LIST_SECOND_VALUE[1]
elif kwargs.get('permissive', False): elif kwargs.get('permissive', False):
raises(PropertiesOptionError, "assert cfg.config(conf).option(pathread, 0).value.get()") raises(PropertiesOptionError, "assert cfg_.option(pathread, 0).value.get()")
raises(PropertiesOptionError, "assert cfg.config(conf).option(pathread, 1).value.get()") raises(PropertiesOptionError, "assert cfg_.option(pathread, 1).value.get()")
assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value
if submulti_: if submulti_:
assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == SUBLIST_SECOND_VALUE[1] assert cfg_.forcepermissive.option(pathread, 1).value.get() == SUBLIST_SECOND_VALUE[1]
else: else:
assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == LIST_SECOND_VALUE[1] assert cfg_.forcepermissive.option(pathread, 1).value.get() == LIST_SECOND_VALUE[1]
else: else:
raises(PropertiesOptionError, "assert cfg.config(conf).option(pathread, 0).value.get()") raises(PropertiesOptionError, "assert cfg_.option(pathread, 0).value.get()")
raises(PropertiesOptionError, "assert cfg.config(conf).option(pathread, 1).value.get()") raises(PropertiesOptionError, "assert cfg_.option(pathread, 1).value.get()")
raises(PropertiesOptionError, "assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get()") raises(PropertiesOptionError, "assert cfg_.forcepermissive.option(pathread, 0).value.get()")
raises(PropertiesOptionError, "assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get()") raises(PropertiesOptionError, "assert cfg_.forcepermissive.option(pathread, 1).value.get()")
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):
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
assert cfg.config(conf).option(pathread).value.get() == first_value assert cfg_.option(pathread).value.get() == first_value
assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value assert cfg_.forcepermissive.option(pathread).value.get() == first_value
elif kwargs.get('permissive', False): elif kwargs.get('permissive', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") raises(PropertiesOptionError, "cfg_.option(pathread).value.get()")
assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value assert cfg_.forcepermissive.option(pathread).value.get() == first_value
else: else:
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") raises(PropertiesOptionError, "cfg_.option(pathread).value.get()")
raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).value.get()") raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).value.get()")
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
do(confread) do(confread)
if confread != confwrite: if confread != confwrite:
@ -515,8 +547,12 @@ def autocheck_value_follower(cfg, mcfg, pathread, pathwrite, confread, confwrite
empty_value = kwargs['default'] empty_value = kwargs['default']
def do(conf): def do(conf):
length = cfg.config(conf).option(pathread).value.len() if conf is not None:
assert cfg.config(conf).forcepermissive.option(pathread).value.len() == length cfg_ = cfg.config(conf)
else:
cfg_ = cfg
length = cfg_.option(pathread).value.len()
assert cfg_.forcepermissive.option(pathread).value.len() == length
assert length == 2 assert length == 2
do(confread) do(confread)
if confread != confwrite: if confread != confwrite:
@ -567,33 +603,41 @@ def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, *
# reset value without permissive # reset value without permissive
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
if confwrite is not None:
cfg_ = cfg.config(confwrite)
else:
cfg_ = cfg
if not isfollower: if not isfollower:
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
cfg.config(confwrite).option(pathwrite).value.reset() cfg_.option(pathwrite).value.reset()
#else: #else:
#FIXME raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite).value.reset()") #FIXME raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite).value.reset()")
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):
cfg.config(confwrite).option(pathwrite, 0).value.reset() cfg_.option(pathwrite, 0).value.reset()
#else: #else:
#FIXME raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite, 0).value.reset()") #FIXME raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite, 0).value.reset()")
# get value after reset value without permissive # get value after reset value without permissive
def do(conf): def do(conf):
if confwrite is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
if isfollower: if isfollower:
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 cfg.config(conf).option(pathread, 0).value.get() == empty_value assert cfg_.option(pathread, 0).value.get() == empty_value
assert cfg.config(conf).option(pathread, 1).value.get() == second_value[1] assert cfg_.option(pathread, 1).value.get() == second_value[1]
elif kwargs.get('permissive', False): elif kwargs.get('permissive', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).value.get()") raises(PropertiesOptionError, "cfg_.option(pathread, 0).value.get()")
assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value
assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == second_value[1] assert cfg_.forcepermissive.option(pathread, 1).value.get() == second_value[1]
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 cfg.config(conf).option(pathread).value.get() == empty_value assert cfg_.option(pathread).value.get() == empty_value
elif kwargs.get('permissive', False): elif kwargs.get('permissive', False):
raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") raises(PropertiesOptionError, "cfg_.option(pathread).value.get()")
assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value assert cfg_.forcepermissive.option(pathread).value.get() == first_value
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
do(confread) do(confread)
if confread != confwrite: if confread != confwrite:
@ -606,16 +650,24 @@ def autocheck_append_value(cfg, mcfg, pathread, pathwrite, confread, confwrite,
submulti_ = cfg.unrestraint.option(pathread).option.issubmulti() submulti_ = cfg.unrestraint.option(pathread).option.issubmulti()
if not isleader: if not isleader:
return return
if confread is not None:
cfg_ = cfg.config(confread)
else:
cfg_ = cfg
if confwrite is not None:
cfg2_ = cfg.config(confwrite)
else:
cfg2_ = cfg
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
if not kwargs.get('propertyerror', False): if not kwargs.get('propertyerror', False):
leader_value = cfg.config(confread).forcepermissive.option(pathread).value.get() leader_value = cfg_.forcepermissive.option(pathread).value.get()
len_value = len(leader_value) len_value = len(leader_value)
leader_value.append(undefined) leader_value.append(undefined)
assert len(cfg.config(confread).forcepermissive.option(pathread).value.get()) == len_value assert len(cfg_.forcepermissive.option(pathread).value.get()) == len_value
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
cfg.forcepermissive.config(confwrite).option(pathread).value.set(leader_value) cfg2_.forcepermissive.option(pathread).value.set(leader_value)
new_leader_value = cfg.config(confread).forcepermissive.option(pathread).value.get() new_leader_value = cfg_.forcepermissive.option(pathread).value.get()
len_new = len(new_leader_value) len_new = len(new_leader_value)
assert len_value + 1 == len_new assert len_value + 1 == len_new
assert new_leader_value[-1] == kwargs['default_multi'] assert new_leader_value[-1] == kwargs['default_multi']
@ -625,16 +677,16 @@ def autocheck_append_value(cfg, mcfg, pathread, pathwrite, confread, confwrite,
else: else:
follower_path += '.third' follower_path += '.third'
for idx in range(len_new): for idx in range(len_new):
assert cfg.config(confread).forcepermissive.option(follower_path, idx).value.get() == kwargs['default_multi'] assert cfg_.forcepermissive.option(follower_path, idx).value.get() == kwargs['default_multi']
# #
if not submulti_: if not submulti_:
value = 'value' value = 'value'
else: else:
value = ['value'] value = ['value']
leader_value.append(value) leader_value.append(value)
assert len(cfg.config(confread).forcepermissive.option(pathread).value.get()) == len(new_leader_value) assert len(cfg_.forcepermissive.option(pathread).value.get()) == len(new_leader_value)
cfg.forcepermissive.config(confwrite).option(pathread).value.set(leader_value) cfg2_.forcepermissive.option(pathread).value.set(leader_value)
assert cfg.config(confread).forcepermissive.option(pathread).value.get()[-1] == value assert cfg_.forcepermissive.option(pathread).value.get()[-1] == value
@autocheck @autocheck
@ -644,6 +696,14 @@ def autocheck_pop_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
if not isleader: if not isleader:
return return
if confwrite is not None:
cfg_ = cfg.config(confwrite)
else:
cfg_ = cfg
if confread is not None:
cfg2_ = cfg.config(confread)
else:
cfg2_ = cfg
if not kwargs.get('propertyerror', False): if not kwargs.get('propertyerror', False):
if not submulti_: if not submulti_:
values = ['value1', 'value2', 'value3', 'value4'] values = ['value1', 'value2', 'value3', 'value4']
@ -658,34 +718,34 @@ def autocheck_pop_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
else: else:
a_follower += '.third' a_follower += '.third'
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
cfg.forcepermissive.config(confwrite).option(pathread).value.set(values) cfg_.forcepermissive.option(pathread).value.set(values)
cfg.forcepermissive.config(confwrite).option(a_follower, 1).value.set(follower_value) cfg_.forcepermissive.option(a_follower, 1).value.set(follower_value)
cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] cfg2_.forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi']
assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True assert cfg2_.forcepermissive.option(a_follower, 0).owner.isdefault() is True
cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == follower_value cfg2_.forcepermissive.option(a_follower, 1).value.get() == follower_value
assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is False assert cfg2_.forcepermissive.option(a_follower, 1).owner.isdefault() is False
cfg.config(confread).forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi'] cfg2_.forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi']
assert cfg.config(confread).forcepermissive.option(a_follower, 2).owner.isdefault() is True assert cfg2_.forcepermissive.option(a_follower, 2).owner.isdefault() is True
cfg.config(confread).forcepermissive.option(a_follower, 3).value.get() == kwargs['default_multi'] cfg2_.forcepermissive.option(a_follower, 3).value.get() == kwargs['default_multi']
assert cfg.config(confread).forcepermissive.option(a_follower, 3).owner.isdefault() is True assert cfg2_.forcepermissive.option(a_follower, 3).owner.isdefault() is True
# #
cfg.forcepermissive.config(confwrite).option(pathread).value.pop(3) cfg_.forcepermissive.option(pathread).value.pop(3)
cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] cfg2_.forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi']
assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True assert cfg2_.forcepermissive.option(a_follower, 0).owner.isdefault() is True
cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == follower_value cfg2_.forcepermissive.option(a_follower, 1).value.get() == follower_value
assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is False assert cfg2_.forcepermissive.option(a_follower, 1).owner.isdefault() is False
cfg.config(confread).forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi'] cfg2_.forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi']
assert cfg.config(confread).forcepermissive.option(a_follower, 2).owner.isdefault() is True assert cfg2_.forcepermissive.option(a_follower, 2).owner.isdefault() is True
# #
cfg.forcepermissive.config(confwrite).option(pathread).value.pop(0) cfg_.forcepermissive.option(pathread).value.pop(0)
cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == follower_value cfg2_.forcepermissive.option(a_follower, 0).value.get() == follower_value
assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is False assert cfg2_.forcepermissive.option(a_follower, 0).owner.isdefault() is False
cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == kwargs['default_multi'] cfg2_.forcepermissive.option(a_follower, 1).value.get() == kwargs['default_multi']
assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is True assert cfg2_.forcepermissive.option(a_follower, 1).owner.isdefault() is True
# #
cfg.forcepermissive.config(confwrite).option(pathread).value.pop(0) cfg_.forcepermissive.option(pathread).value.pop(0)
cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] cfg2_.forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi']
assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True assert cfg2_.forcepermissive.option(a_follower, 0).owner.isdefault() is True
@autocheck @autocheck
@ -697,12 +757,20 @@ def autocheck_reset_value_permissive(cfg, mcfg, pathread, pathwrite, confread, c
with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w:
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
if not isfollower: if not isfollower:
cfg.forcepermissive.config(confwrite).option(pathwrite).value.reset() if confwrite is not None:
cfg_ = cfg.forcepermissive.config(confwrite)
else:
cfg_ = cfg.forcepermissive
cfg_.option(pathwrite).value.reset()
else: else:
cfg.forcepermissive.option(pathwrite, 1).value.reset() cfg.forcepermissive.option(pathwrite, 1).value.reset()
elif kwargs.get('permissive', False): elif kwargs.get('permissive', False):
if not isfollower: if not isfollower:
cfg.forcepermissive.config(confwrite).option(pathwrite).value.reset() if confwrite is not None:
cfg_ = cfg.forcepermissive.config(confwrite)
else:
cfg_ = cfg.forcepermissive
cfg_.option(pathwrite).value.reset()
else: else:
cfg.forcepermissive.option(pathwrite, 1).value.reset() cfg.forcepermissive.option(pathwrite, 1).value.reset()
#FIXME else: #FIXME else:
@ -723,13 +791,21 @@ def autocheck_display(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwa
return return
make_dict = kwargs['make_dict'] make_dict = kwargs['make_dict']
make_dict_value = kwargs['make_dict_value'] make_dict_value = kwargs['make_dict_value']
assert cfg.config(confread).value.dict() == make_dict if confread is not None:
cfg_ = cfg.config(confread)
else:
cfg_ = cfg
if confwrite is not None:
cfg2_ = cfg.config(confwrite)
else:
cfg2_ = cfg
assert cfg_.value.dict() == make_dict
if confread != confwrite: if confread != confwrite:
assert(cfg.config(confwrite).value.dict()) == make_dict assert(cfg2_.value.dict()) == make_dict
_set_value(cfg, pathwrite, confwrite, **kwargs) _set_value(cfg, pathwrite, confwrite, **kwargs)
assert cfg.config(confread).value.dict() == make_dict_value assert cfg_.value.dict() == make_dict_value
if confread != confwrite: if confread != confwrite:
assert(cfg.config(confwrite).value.dict()) == make_dict_value assert(cfg2_.value.dict()) == make_dict_value
@autocheck @autocheck
@ -749,7 +825,11 @@ def autocheck_property(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kw
# set properties without permissive # set properties without permissive
for prop in properties: for prop in properties:
cfg.unrestraint.config(confwrite).option(pathwrite).property.add(prop) if confwrite is not None:
cfg_ = cfg.unrestraint.config(confwrite)
else:
cfg_ = cfg.unrestraint
cfg_.option(pathwrite).property.add(prop)
if confread == confwrite: if confread == confwrite:
_check_properties(cfg, mcfg, pathread, confread, kwargs, properties, properties) _check_properties(cfg, mcfg, pathread, confread, kwargs, properties, properties)
else: else:
@ -774,7 +854,11 @@ def autocheck_reset_property(cfg, mcfg, pathread, pathwrite, confread, confwrite
_property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs) _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs)
# reset properties without permissive # reset properties without permissive
cfg.unrestraint.config(confwrite).option(pathwrite).property.reset() if confwrite is not None:
cfg_ = cfg.unrestraint.config(confwrite)
else:
cfg_ = cfg.unrestraint
cfg_.option(pathwrite).property.reset()
if confread == confwrite: if confread == confwrite:
_check_properties(cfg, mcfg, pathread, confread, kwargs, default_props, default_props) _check_properties(cfg, mcfg, pathread, confread, kwargs, default_props, default_props)
@ -819,22 +903,28 @@ def autocheck_default_owner_with_value(cfg, mcfg, pathread, pathwrite, confread,
isfollower = cfg.unrestraint.option(pathread).option.isfollower() isfollower = cfg.unrestraint.option(pathread).option.isfollower()
_set_value(cfg, pathwrite, confwrite, **kwargs) _set_value(cfg, pathwrite, confwrite, **kwargs)
if confwrite is not None:
cfg_ = cfg.config(confread)
cfg2_ = cfg.config(confwrite)
else:
cfg_ = cfg
cfg2_ = cfg
# test if is default owner without permissive # test if is default owner without permissive
if not isfollower: if not isfollower:
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 cfg.config(confwrite).option(pathread).owner.isdefault() is False assert cfg_.option(pathread).owner.isdefault() is False
if confwrite != confread: if confwrite != confread:
assert cfg.config(confread).option(pathread).owner.isdefault() is False assert cfg2_.option(pathread).owner.isdefault() is False
#FIXME else: #FIXME else:
# raises(PropertiesOptionError, "cfg.config(confwrite).option(pathread).owner.isdefault()") # raises(PropertiesOptionError, "cfg.config(confwrite).option(pathread).owner.isdefault()")
# raises(PropertiesOptionError, "cfg.config(confread).option(pathread).owner.isdefault()") # raises(PropertiesOptionError, "cfg.config(confread).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 cfg.config(confwrite).option(pathread, 0).owner.isdefault() is True assert cfg2_.option(pathread, 0).owner.isdefault() is True
assert cfg.config(confwrite).option(pathread, 1).owner.isdefault() is False assert cfg2_.option(pathread, 1).owner.isdefault() is False
if confwrite != confread: if confwrite != confread:
assert cfg.config(confread).option(pathread, 0).owner.isdefault() is True assert cfg_.option(pathread, 0).owner.isdefault() is True
assert cfg.config(confread).option(pathread, 1).owner.isdefault() is False assert cfg_.option(pathread, 1).owner.isdefault() is False
#FIXME else: #FIXME else:
# raises(PropertiesOptionError, "cfg.config(confwrite).option(pathread, 0).owner.isdefault()") # raises(PropertiesOptionError, "cfg.config(confwrite).option(pathread, 0).owner.isdefault()")
# raises(PropertiesOptionError, "cfg.config(confread).option(pathread, 0).owner.isdefault()") # raises(PropertiesOptionError, "cfg.config(confread).option(pathread, 0).owner.isdefault()")
@ -849,12 +939,16 @@ def autocheck_default_owner_with_value_permissive(cfg, mcfg, pathread, pathwrite
def do(conf): def do(conf):
# test if is default owner with permissive # test if is default owner with permissive
if conf is not None:
cfg_ = cfg.config(conf)
else:
cfg_ = cfg
if not kwargs.get('propertyerror', False): if not kwargs.get('propertyerror', False):
if not isfollower: if not isfollower:
assert cfg.config(conf).forcepermissive.option(pathread).owner.isdefault() is False assert cfg_.forcepermissive.option(pathread).owner.isdefault() is False
else: else:
assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.isdefault() is True assert cfg_.forcepermissive.option(pathread, 0).owner.isdefault() is True
assert cfg.config(conf).forcepermissive.option(pathread, 1).owner.isdefault() is False assert cfg_.forcepermissive.option(pathread, 1).owner.isdefault() is False
#FIXME else: #FIXME else:
# raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.isdefault()") # raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.isdefault()")
do(confwrite) do(confwrite)
@ -865,11 +959,15 @@ def autocheck_default_owner_with_value_permissive(cfg, mcfg, pathread, pathwrite
@autocheck @autocheck
def autocheck_set_owner_no_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs): def autocheck_set_owner_no_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs):
isfollower = cfg.unrestraint.option(pathread).option.isfollower() isfollower = cfg.unrestraint.option(pathread).option.isfollower()
if confwrite is not None:
cfg_ = cfg.forcepermissive.config(confwrite)
else:
cfg_ = cfg.forcepermissive
if not kwargs.get('propertyerror', False): if not kwargs.get('propertyerror', False):
if not isfollower: if not isfollower:
raises(ConfigError, "cfg.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user')") raises(ConfigError, "cfg_.option(pathwrite).owner.set('new_user')")
else: else:
raises(ConfigError, "cfg.forcepermissive.option(pathwrite, 1).owner.set('new_user')") raises(ConfigError, "cfg_.option(pathwrite, 1).owner.set('new_user')")
@autocheck @autocheck
@ -878,13 +976,17 @@ def autocheck_set_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k
isfollower = cfg.unrestraint.option(pathread).option.isfollower() isfollower = cfg.unrestraint.option(pathread).option.isfollower()
_set_value(cfg, pathwrite, confwrite, **kwargs) _set_value(cfg, pathwrite, confwrite, **kwargs)
if confwrite is not None:
cfg_ = cfg.config(confwrite)
else:
cfg_ = cfg
# set owner without permissive # set owner without permissive
if not isfollower: if not isfollower:
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
cfg.config(confwrite).option(pathwrite).owner.set('new_user') cfg_.option(pathwrite).owner.set('new_user')
raises(ValueError, "cfg.config(confwrite).option(pathwrite).owner.set('default')") raises(ValueError, "cfg_.option(pathwrite).owner.set('default')")
raises(ValueError, "cfg.config(confwrite).option(pathwrite).owner.set('forced')") raises(ValueError, "cfg_.option(pathwrite).owner.set('forced')")
#FIXME else: #FIXME else:
# raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite).owner.set('new_user')") # raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite).owner.set('new_user')")
else: else:
@ -903,11 +1005,15 @@ def autocheck_set_owner_permissive(cfg, mcfg, pathread, pathwrite, confread, con
isfollower = cfg.unrestraint.option(pathread).option.isfollower() isfollower = cfg.unrestraint.option(pathread).option.isfollower()
_set_value(cfg, pathwrite, confwrite, **kwargs) _set_value(cfg, pathwrite, confwrite, **kwargs)
if confwrite is not None:
cfg_ = cfg.forcepermissive.config(confwrite)
else:
cfg_ = cfg.forcepermissive
# set owner with permissive # set owner with permissive
if not kwargs.get('propertyerror', False): if not kwargs.get('propertyerror', False):
if not isfollower: if not isfollower:
cfg.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user1') cfg_.option(pathwrite).owner.set('new_user1')
else: else:
cfg.forcepermissive.option(pathwrite, 1).owner.set('new_user1') cfg.forcepermissive.option(pathwrite, 1).owner.set('new_user1')
#FIXME else: #FIXME else:
@ -961,9 +1067,17 @@ def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
"""test permissive for hidden and disabled value """test permissive for hidden and disabled value
""" """
# no permissive before # no permissive before
assert cfg.unrestraint.config(confwrite).option(pathread).permissive.get() == frozenset() if confwrite is not None:
cfg_ = cfg.unrestraint.config(confwrite)
else:
cfg_ = cfg.unrestraint
if confread is not None:
cfg2_ = cfg.config(confread).unrestraint
else:
cfg2_ = cfg.unrestraint
assert cfg_.option(pathread).permissive.get() == frozenset()
if kwargs.get('permissive_od', False): if kwargs.get('permissive_od', False):
assert cfg.unrestraint.config(confwrite).option(pathread.rsplit('.', 1)[0]).permissive.get() == frozenset() assert cfg_.option(pathread.rsplit('.', 1)[0]).permissive.get() == frozenset()
# cannot access to hidden value without forcepermissive # cannot access to hidden value without forcepermissive
# and to disabled value (with forcepermissive too) # and to disabled value (with forcepermissive too)
@ -972,17 +1086,17 @@ def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
_autocheck_default_value(cfg, pathread, confread, **kwargs) _autocheck_default_value(cfg, pathread, confread, **kwargs)
# set permissive # set permissive
cfg.unrestraint.config(confwrite).option(pathwrite).permissive.set(frozenset(['disabled'])) cfg_.option(pathwrite).permissive.set(frozenset(['disabled']))
callback = kwargs['callback'] callback = kwargs['callback']
if callback: if callback:
if pathread.endswith('val1') or pathread.endswith('val2'): if pathread.endswith('val1') or pathread.endswith('val2'):
call_path = pathread[:-4] + 'call' + pathread[-4:] call_path = pathread[:-4] + 'call' + pathread[-4:]
else: else:
call_path = pathread + 'call' call_path = pathread + 'call'
cfg.unrestraint.config(confwrite).option(call_path).permissive.set(frozenset(['disabled'])) cfg_.option(call_path).permissive.set(frozenset(['disabled']))
# have permissive? # have permissive?
assert cfg.unrestraint.config(confwrite).option(pathread).permissive.get() == frozenset(['disabled']) assert cfg_.option(pathread).permissive.get() == frozenset(['disabled'])
#if confwrite != confread: #if confwrite != confread:
# assert cfg.config(confread).unrestraint.option(pathread).permissive.get() == frozenset(['disabled']) # assert cfg.config(confread).unrestraint.option(pathread).permissive.get() == frozenset(['disabled'])
@ -991,9 +1105,9 @@ def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
ckwargs['propertyerror'] = False ckwargs['propertyerror'] = False
_autocheck_default_value(cfg, pathread, confwrite, **ckwargs) _autocheck_default_value(cfg, pathread, confwrite, **ckwargs)
cfg.config(confread).unrestraint.option(pathwrite).permissive.set(frozenset(['disabled', 'hidden'])) cfg2_.option(pathwrite).permissive.set(frozenset(['disabled', 'hidden']))
if kwargs['callback']: if kwargs['callback']:
cfg.config(confread).unrestraint.option(call_path).permissive.set(frozenset(['disabled', 'hidden'])) cfg2_.option(call_path).permissive.set(frozenset(['disabled', 'hidden']))
# can access to all value except when optiondescript have hidden # can access to all value except when optiondescript have hidden
if not ckwargs.get('permissive_od', False): if not ckwargs.get('permissive_od', False):
@ -1002,7 +1116,7 @@ def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
if ckwargs.get('permissive_od', False): if ckwargs.get('permissive_od', False):
# set permissive to OptionDescription # set permissive to OptionDescription
cfg.config(confread).unrestraint.option(pathwrite.rsplit('.', 1)[0]).permissive.set(frozenset(['disabled', cfg2_.option(pathwrite.rsplit('.', 1)[0]).permissive.set(frozenset(['disabled',
'hidden'])) 'hidden']))
ckwargs['permissive'] = False ckwargs['permissive'] = False
_autocheck_default_value(cfg, pathread, confread, **ckwargs) _autocheck_default_value(cfg, pathread, confread, **ckwargs)
@ -1010,23 +1124,23 @@ def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **
# _autocheck_default_value(cfg, pathread, confwrite, **ckwargs) # _autocheck_default_value(cfg, pathread, confwrite, **ckwargs)
# only hidden # only hidden
cfg.config(confread).unrestraint.option(pathwrite).permissive.set(frozenset(['hidden'])) cfg2_.option(pathwrite).permissive.set(frozenset(['hidden']))
if callback: if callback:
cfg.config(confread).unrestraint.option(call_path).permissive.set(frozenset(['hidden'])) cfg2_.option(call_path).permissive.set(frozenset(['hidden']))
if ckwargs.get('permissive_od', False): if ckwargs.get('permissive_od', False):
_autocheck_default_value(cfg, pathread, confread, **ckwargs) _autocheck_default_value(cfg, pathread, confread, **ckwargs)
cfg.config(confread).unrestraint.option(pathwrite.rsplit('.', 1)[0]).permissive.set(frozenset(['hidden'])) cfg2_.option(pathwrite.rsplit('.', 1)[0]).permissive.set(frozenset(['hidden']))
ckwargs = copy(kwargs) ckwargs = copy(kwargs)
ckwargs['permissive'] = False ckwargs['permissive'] = False
_autocheck_default_value(cfg, pathread, confread, **ckwargs) _autocheck_default_value(cfg, pathread, confread, **ckwargs)
# no permissive # no permissive
cfg.config(confread).unrestraint.option(pathwrite).permissive.set(frozenset()) cfg2_.option(pathwrite).permissive.set(frozenset())
if callback: if callback:
cfg.config(confread).unrestraint.option(call_path).permissive.set(frozenset()) cfg2_.option(call_path).permissive.set(frozenset())
if ckwargs.get('permissive_od', False): if ckwargs.get('permissive_od', False):
_autocheck_default_value(cfg, pathread, confread, **ckwargs) _autocheck_default_value(cfg, pathread, confread, **ckwargs)
cfg.config(confread).unrestraint.option(pathwrite.rsplit('.', 1)[0]).permissive.set(frozenset()) cfg2_.option(pathwrite.rsplit('.', 1)[0]).permissive.set(frozenset())
_autocheck_default_value(cfg, pathread, confread, **kwargs) _autocheck_default_value(cfg, pathread, confread, **kwargs)
@ -1060,17 +1174,21 @@ def autocheck_find(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs
option = _getoption(cfg.unrestraint.option(pathread)) option = _getoption(cfg.unrestraint.option(pathread))
def do(conf): def do(conf):
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if conf is not None:
assert option == _getoption(cfg.config(conf).option.find(name, first=True)) cfg_ = cfg.config(conf)
assert option == _getoption(cfg.config(conf).forcepermissive.option.find(name, first=True))
elif kwargs.get('permissive', False):
raises(AttributeError, "cfg.config(conf).option.find(name, first=True)")
assert option == _getoption(cfg.config(conf).forcepermissive.option.find(name, first=True))
else: else:
raises(AttributeError, "cfg.config(conf).option.find(name, first=True)") cfg_ = cfg
raises(AttributeError, "cfg.config(conf).forcepermissive.option.find(name, first=True)") if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
assert option == _getoption(cfg.config(conf).unrestraint.option.find(name, first=True)) assert option == _getoption(cfg_.option.find(name, first=True))
assert [option] == _getoptions(cfg.config(conf).unrestraint.option.find(name)) assert option == _getoption(cfg_.forcepermissive.option.find(name, first=True))
elif kwargs.get('permissive', False):
raises(AttributeError, "cfg_.option.find(name, first=True)")
assert option == _getoption(cfg_.forcepermissive.option.find(name, first=True))
else:
raises(AttributeError, "cfg_.option.find(name, first=True)")
raises(AttributeError, "cfg_.forcepermissive.option.find(name, first=True)")
assert option == _getoption(cfg_.unrestraint.option.find(name, first=True))
assert [option] == _getoptions(cfg_.unrestraint.option.find(name))
do(confread) do(confread)
if confread != confwrite: if confread != confwrite:
do(confwrite) do(confwrite)