From d25edd7dd7d9a7e82fd86d5cc345dd0cbd96ae02 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 2 Mar 2019 19:30:21 +0100 Subject: [PATCH] update test_auto (fixes #2) --- test/auto/test_auto.py | 594 ++++++++++++++++++++++++----------------- 1 file changed, 356 insertions(+), 238 deletions(-) diff --git a/test/auto/test_auto.py b/test/auto/test_auto.py index 1396ed4..7a4eef3 100644 --- a/test/auto/test_auto.py +++ b/test/auto/test_auto.py @@ -83,30 +83,34 @@ def _autocheck_default_value(cfg, path, conf, **kwargs): # test default value (should be empty) # 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: if not isfollower: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - assert cfg.config(conf).option(path).value.get() == empty_value - assert cfg.config(conf).forcepermissive.option(path).value.get() == empty_value + assert cfg_.option(path).value.get() == empty_value + assert cfg_.forcepermissive.option(path).value.get() == empty_value elif not kwargs.get('propertyerror', False): - raises(PropertiesOptionError, "cfg.config(conf).option(path).value.get()") - assert cfg.config(conf).forcepermissive.option(path).value.get() == empty_value + raises(PropertiesOptionError, "cfg_.option(path).value.get()") + assert cfg_.forcepermissive.option(path).value.get() == empty_value else: - raises(PropertiesOptionError, "cfg.config(conf).option(path).value.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(path).value.get()") + raises(PropertiesOptionError, "cfg_.option(path).value.get()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(path).value.get()") else: 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.config(conf).option(path, 1).value.get() == empty_value - assert cfg.config(conf).forcepermissive.option(path, 0).value.get() == empty_value - assert cfg.config(conf).forcepermissive.option(path, 1).value.get() == empty_value + assert cfg_.option(path, 0).value.get() == empty_value + assert cfg_.option(path, 1).value.get() == empty_value + assert cfg_.forcepermissive.option(path, 0).value.get() == empty_value + assert cfg_.forcepermissive.option(path, 1).value.get() == empty_value elif not kwargs.get('propertyerror', False): - raises(PropertiesOptionError, "cfg.config(conf).option(path, 0).value.get()") - assert cfg.config(conf).forcepermissive.option(path, 0).value.get() == empty_value - assert cfg.config(conf).forcepermissive.option(path, 1).value.get() == empty_value + raises(PropertiesOptionError, "cfg_.option(path, 0).value.get()") + assert cfg_.forcepermissive.option(path, 0).value.get() == empty_value + assert cfg_.forcepermissive.option(path, 1).value.get() == empty_value else: - raises(PropertiesOptionError, "cfg.config(conf).option(path, 0).value.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(path, 0).value.get()") + raises(PropertiesOptionError, "cfg_.option(path, 0).value.get()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(path, 0).value.get()") 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 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: if isleader: 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: - cfg.config(conf).option(pathwrite).value.set([first_value[0]]) + cfg_.option(pathwrite).value.set([first_value[0]]) 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): - 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: - cfg.config(conf).forcepermissive.option(pathwrite).value.set([first_value[0]]) + cfg_.forcepermissive.option(pathwrite).value.set([first_value[0]]) else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite).value.set([first_value[0]])") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathwrite).value.set([first_value[0]])") + raises(PropertiesOptionError, "cfg_.option(pathwrite).value.set([first_value[0]])") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathwrite).value.set([first_value[0]])") 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: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if not set_permissive: - cfg.config(conf).option(pathwrite, 1).value.set(second_value) + cfg_.option(pathwrite, 1).value.set(second_value) 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): - 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: - cfg.config(conf).forcepermissive.option(pathwrite, 1).value.set(second_value) + cfg_.forcepermissive.option(pathwrite, 1).value.set(second_value) else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite, 1).value.set(second_value)") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathwrite, 1).value.set(second_value)") - raises(APIError, "cfg.config(conf).unrestraint.option(pathwrite).value.set([second_value, second_value])") + raises(PropertiesOptionError, "cfg_.option(pathwrite, 1).value.set(second_value)") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathwrite, 1).value.set(second_value)") + raises(APIError, "cfg_.unrestraint.option(pathwrite).value.set([second_value, second_value])") else: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): if not set_permissive: - cfg.config(conf).option(pathwrite).value.set(first_value) + cfg_.option(pathwrite).value.set(first_value) 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): - raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite).value.set(first_value)") + raises(PropertiesOptionError, "cfg_.option(pathwrite).value.set(first_value)") if set_permissive: - cfg.config(conf).forcepermissive.option(pathwrite).value.set(first_value) + cfg_.forcepermissive.option(pathwrite).value.set(first_value) else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathwrite).value.set(first_value)") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathwrite).value.set(first_value)") - #FIXME raises(APIError, "cfg.config(conf).unrestraint.option(pathwrite).value.set(first_value)") + raises(PropertiesOptionError, "cfg_.option(pathwrite).value.set(first_value)") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathwrite).value.set(first_value)") + #FIXME raises(APIError, "cfg_.unrestraint.option(pathwrite).value.set(first_value)") 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): + if conf is not None: + cfg_ = cfg.config(conf) + else: + cfg_ = cfg if not cfg.unrestraint.option(pathread).option.isfollower(): if not kwargs.get('permissive_od', False): - assert set(cfg.config(conf).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_permissive) + assert set(cfg_.option(pathread).property.get()) == set(props) else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).property.get()") - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).property.get()") - assert set(cfg.config(conf).forcepermissive.option(pathread).property.get()) == set(props_permissive) - assert set(cfg.config(conf).forcepermissive.option(pathread).property.get()) == set(props) - assert set(cfg.config(conf).unrestraint.option(pathread).property.get()) == set(props_permissive) - assert set(cfg.config(conf).unrestraint.option(pathread).property.get()) == set(props) + raises(PropertiesOptionError, "cfg_.option(pathread).property.get()") + raises(PropertiesOptionError, "cfg_.option(pathread).property.get()") + assert set(cfg_.forcepermissive.option(pathread).property.get()) == set(props_permissive) + assert set(cfg_.forcepermissive.option(pathread).property.get()) == set(props) + assert set(cfg_.unrestraint.option(pathread).property.get()) == set(props_permissive) + assert set(cfg_.unrestraint.option(pathread).property.get()) == set(props) else: if not kwargs.get('permissive_od', False): - assert set(cfg.config(conf).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_permissive) + 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.config(conf).option(pathread, 1).property.get()) == set(props) + assert set(cfg_.option(pathread, 1).property.get()) == set(props_permissive) + assert set(cfg_.option(pathread, 1).property.get()) == set(props) else: - raises(PropertiesOptionError, "cfg.config(conf).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_.option(pathread, 0).property.get()") # - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 1).property.get()") - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 1).property.get()") - assert set(cfg.config(conf).forcepermissive.option(pathread, 0).property.get()) == set(props_permissive) - assert set(cfg.config(conf).forcepermissive.option(pathread, 0).property.get()) == set(props) + raises(PropertiesOptionError, "cfg_.option(pathread, 1).property.get()") + raises(PropertiesOptionError, "cfg_.option(pathread, 1).property.get()") + assert set(cfg_.forcepermissive.option(pathread, 0).property.get()) == set(props_permissive) + 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.config(conf).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.config(conf).unrestraint.option(pathread, 1).property.get()) == set(props) + assert set(cfg_.forcepermissive.option(pathread, 1).property.get()) == set(props_permissive) + assert set(cfg_.forcepermissive.option(pathread, 1).property.get()) == set(props) + assert set(cfg_.unrestraint.option(pathread, 1).property.get()) == set(props_permissive) + assert set(cfg_.unrestraint.option(pathread, 1).property.get()) == set(props) 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 for prop in properties: - if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - cfg.config(confread).option(pathwrite).property.add(prop) - elif not kwargs.get('propertyerror', False): - cfg.config(confread).forcepermissive.option(pathwrite).property.add(prop) + if confread is not None: + cfg_ = cfg.config(confread) 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: _check_properties(cfg, mcfg, pathread, confwrite, kwargs, properties, properties) else: @@ -286,64 +302,72 @@ def _autocheck_get_value(cfg, pathread, conf, **kwargs): second_value = SUBLIST_SECOND_VALUE[1] # 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: if isfollower: 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.config(conf).option(pathread, 1).value.get() == second_value - assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value - assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == second_value + assert cfg_.option(pathread, 0).value.get() == empty_value + assert cfg_.option(pathread, 1).value.get() == second_value + assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value + assert cfg_.forcepermissive.option(pathread, 1).value.get() == second_value elif kwargs.get('permissive', False): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).value.get()") - assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value + raises(PropertiesOptionError, "cfg_.option(pathread, 0).value.get()") + assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value 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: - assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == empty_value + assert cfg_.forcepermissive.option(pathread, 1).value.get() == empty_value else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).value.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread, 0).value.get()") + raises(PropertiesOptionError, "cfg_.option(pathread, 0).value.get()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread, 0).value.get()") else: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - assert cfg.config(conf).option(pathread).value.get() == first_value - assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value + assert cfg_.option(pathread).value.get() == first_value + assert cfg_.forcepermissive.option(pathread).value.get() == first_value elif kwargs.get('permissive', False): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") + raises(PropertiesOptionError, "cfg_.option(pathread).value.get()") if set_permissive: - assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value + assert cfg_.forcepermissive.option(pathread).value.get() == first_value else: - assert cfg.config(conf).forcepermissive.option(pathread).value.get() == empty_value + assert cfg_.forcepermissive.option(pathread).value.get() == empty_value else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).value.get()") + raises(PropertiesOptionError, "cfg_.option(pathread).value.get()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).value.get()") def _check_owner(cfg, pathread, conf, kwargs, owner, permissive_owner): isfollower = cfg.unrestraint.option(pathread).option.isfollower() + if conf is not None: + cfg_ = cfg.config(conf) + else: + cfg_ = cfg if not isfollower: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - assert cfg.config(conf).option(pathread).owner.get() == owner - assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == owner + assert cfg_.option(pathread).owner.get() == owner + assert cfg_.forcepermissive.option(pathread).owner.get() == owner elif not kwargs.get('propertyerror', False): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.get()") - assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == permissive_owner + raises(PropertiesOptionError, "cfg_.option(pathread).owner.get()") + assert cfg_.forcepermissive.option(pathread).owner.get() == permissive_owner else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.get()") + raises(PropertiesOptionError, "cfg_.option(pathread).owner.get()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).owner.get()") else: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - assert cfg.config(conf).option(pathread, 0).owner.get() == 'default' - assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.get() == 'default' - assert cfg.config(conf).option(pathread, 1).owner.get() == owner - assert cfg.config(conf).forcepermissive.option(pathread, 1).owner.get() == owner + assert cfg_.option(pathread, 0).owner.get() == 'default' + assert cfg_.forcepermissive.option(pathread, 0).owner.get() == 'default' + assert cfg_.option(pathread, 1).owner.get() == owner + assert cfg_.forcepermissive.option(pathread, 1).owner.get() == owner elif not kwargs.get('propertyerror', False): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.get()") - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 1).owner.get()") - assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.get() == 'default' - assert cfg.config(conf).forcepermissive.option(pathread, 1).owner.get() == permissive_owner + raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.get()") + raises(PropertiesOptionError, "cfg_.option(pathread, 1).owner.get()") + assert cfg_.forcepermissive.option(pathread, 0).owner.get() == 'default' + assert cfg_.forcepermissive.option(pathread, 1).owner.get() == permissive_owner else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread, 0).owner.get()") + raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.get()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread, 0).owner.get()") @autocheck @@ -373,49 +397,53 @@ def autocheck_default_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, isfollower = cfg.unrestraint.option(pathread).option.isfollower() # check if owner is a string "default" and 'isdefault' def do(conf): + if conf is not None: + cfg_ = cfg.config(conf) + else: + cfg_ = cfg if not isfollower: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - assert cfg.config(conf).option(pathread).owner.get() == 'default' - assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == 'default' + assert cfg_.option(pathread).owner.get() == 'default' + assert cfg_.forcepermissive.option(pathread).owner.get() == 'default' # - assert cfg.config(conf).option(pathread).owner.isdefault() - assert cfg.config(conf).forcepermissive.option(pathread).owner.isdefault() + assert cfg_.option(pathread).owner.isdefault() + assert cfg_.forcepermissive.option(pathread).owner.isdefault() elif not kwargs.get('propertyerror', False): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.get()") - assert cfg.config(conf).forcepermissive.option(pathread).owner.get() == 'default' + raises(PropertiesOptionError, "cfg_.option(pathread).owner.get()") + assert cfg_.forcepermissive.option(pathread).owner.get() == 'default' # - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.isdefault()") - assert cfg.config(conf).forcepermissive.option(pathread).owner.isdefault() + raises(PropertiesOptionError, "cfg_.option(pathread).owner.isdefault()") + assert cfg_.forcepermissive.option(pathread).owner.isdefault() else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.get()") + raises(PropertiesOptionError, "cfg_.option(pathread).owner.get()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).owner.get()") # - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).owner.isdefault()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.isdefault()") + raises(PropertiesOptionError, "cfg_.option(pathread).owner.isdefault()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).owner.isdefault()") # - assert cfg.config(conf).unrestraint.option(pathread).owner.get() == 'default' - assert cfg.config(conf).unrestraint.option(pathread).owner.isdefault() + assert cfg_.unrestraint.option(pathread).owner.get() == 'default' + assert cfg_.unrestraint.option(pathread).owner.isdefault() else: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - assert cfg.config(conf).option(pathread, 0).owner.get() == 'default' - assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.get() == 'default' + assert cfg_.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.config(conf).forcepermissive.option(pathread, 0).owner.isdefault() + assert cfg_.option(pathread, 0).owner.isdefault() + assert cfg_.forcepermissive.option(pathread, 0).owner.isdefault() elif not kwargs.get('propertyerror', False): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.get()") - assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.get() == 'default' + raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.get()") + assert cfg_.forcepermissive.option(pathread, 0).owner.get() == 'default' # - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.isdefault()") - assert cfg.config(conf).forcepermissive.option(pathread, 0).owner.isdefault() + raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.isdefault()") + assert cfg_.forcepermissive.option(pathread, 0).owner.isdefault() else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).owner.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread, 0).owner.get()") + raises(PropertiesOptionError, "cfg_.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.config(conf).forcepermissive.option(pathread, 0).owner.isdefault()") - assert cfg.config(conf).unrestraint.option(pathread, 0).owner.get() == 'default' - assert cfg.config(conf).unrestraint.option(pathread, 0).owner.isdefault() + raises(PropertiesOptionError, "cfg_.option(pathread, 0).owner.isdefault()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread, 0).owner.isdefault()") + assert cfg_.unrestraint.option(pathread, 0).owner.get() == 'default' + assert cfg_.unrestraint.option(pathread, 0).owner.isdefault() do(confread) if confread != confwrite: do(confwrite) @@ -450,40 +478,44 @@ def autocheck_get_value_permissive(cfg, mcfg, pathread, pathwrite, confread, con def do(conf): # get value after set value without permissive + if conf is not None: + cfg_ = cfg.config(conf) + else: + cfg_ = cfg if isfollower: 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.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value + assert cfg_.option(pathread, 0).value.get() == empty_value + assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value if submulti_: - assert cfg.config(conf).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_.option(pathread, 1).value.get() == SUBLIST_SECOND_VALUE[1] + assert cfg_.forcepermissive.option(pathread, 1).value.get() == SUBLIST_SECOND_VALUE[1] else: - assert cfg.config(conf).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_.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): - raises(PropertiesOptionError, "assert cfg.config(conf).option(pathread, 0).value.get()") - raises(PropertiesOptionError, "assert cfg.config(conf).option(pathread, 1).value.get()") - assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value + raises(PropertiesOptionError, "assert cfg_.option(pathread, 0).value.get()") + raises(PropertiesOptionError, "assert cfg_.option(pathread, 1).value.get()") + assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value 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: - 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: - raises(PropertiesOptionError, "assert cfg.config(conf).option(pathread, 0).value.get()") - raises(PropertiesOptionError, "assert cfg.config(conf).option(pathread, 1).value.get()") - raises(PropertiesOptionError, "assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get()") - raises(PropertiesOptionError, "assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get()") + raises(PropertiesOptionError, "assert cfg_.option(pathread, 0).value.get()") + raises(PropertiesOptionError, "assert cfg_.option(pathread, 1).value.get()") + raises(PropertiesOptionError, "assert cfg_.forcepermissive.option(pathread, 0).value.get()") + raises(PropertiesOptionError, "assert cfg_.forcepermissive.option(pathread, 1).value.get()") else: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): with warnings.catch_warnings(record=True) as w: - assert cfg.config(conf).option(pathread).value.get() == first_value - assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value + assert cfg_.option(pathread).value.get() == first_value + assert cfg_.forcepermissive.option(pathread).value.get() == first_value elif kwargs.get('permissive', False): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") - assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value + raises(PropertiesOptionError, "cfg_.option(pathread).value.get()") + assert cfg_.forcepermissive.option(pathread).value.get() == first_value else: - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") - raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).value.get()") + raises(PropertiesOptionError, "cfg_.option(pathread).value.get()") + raises(PropertiesOptionError, "cfg_.forcepermissive.option(pathread).value.get()") with warnings.catch_warnings(record=True) as w: do(confread) if confread != confwrite: @@ -515,8 +547,12 @@ def autocheck_value_follower(cfg, mcfg, pathread, pathwrite, confread, confwrite empty_value = kwargs['default'] def do(conf): - length = cfg.config(conf).option(pathread).value.len() - assert cfg.config(conf).forcepermissive.option(pathread).value.len() == length + if conf is not None: + cfg_ = cfg.config(conf) + else: + cfg_ = cfg + length = cfg_.option(pathread).value.len() + assert cfg_.forcepermissive.option(pathread).value.len() == length assert length == 2 do(confread) if confread != confwrite: @@ -567,33 +603,41 @@ def autocheck_reset_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, * # reset value without permissive 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 kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - cfg.config(confwrite).option(pathwrite).value.reset() + cfg_.option(pathwrite).value.reset() #else: #FIXME raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite).value.reset()") else: 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: #FIXME raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite, 0).value.reset()") # get value after reset value without permissive def do(conf): + if confwrite is not None: + cfg_ = cfg.config(conf) + else: + cfg_ = cfg if isfollower: 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.config(conf).option(pathread, 1).value.get() == second_value[1] + assert cfg_.option(pathread, 0).value.get() == empty_value + assert cfg_.option(pathread, 1).value.get() == second_value[1] elif kwargs.get('permissive', False): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread, 0).value.get()") - assert cfg.config(conf).forcepermissive.option(pathread, 0).value.get() == empty_value - assert cfg.config(conf).forcepermissive.option(pathread, 1).value.get() == second_value[1] + raises(PropertiesOptionError, "cfg_.option(pathread, 0).value.get()") + assert cfg_.forcepermissive.option(pathread, 0).value.get() == empty_value + assert cfg_.forcepermissive.option(pathread, 1).value.get() == second_value[1] else: 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): - raises(PropertiesOptionError, "cfg.config(conf).option(pathread).value.get()") - assert cfg.config(conf).forcepermissive.option(pathread).value.get() == first_value + raises(PropertiesOptionError, "cfg_.option(pathread).value.get()") + assert cfg_.forcepermissive.option(pathread).value.get() == first_value with warnings.catch_warnings(record=True) as w: do(confread) if confread != confwrite: @@ -606,16 +650,24 @@ def autocheck_append_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, submulti_ = cfg.unrestraint.option(pathread).option.issubmulti() if not isleader: 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: 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) 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: - cfg.forcepermissive.config(confwrite).option(pathread).value.set(leader_value) - new_leader_value = cfg.config(confread).forcepermissive.option(pathread).value.get() + cfg2_.forcepermissive.option(pathread).value.set(leader_value) + new_leader_value = cfg_.forcepermissive.option(pathread).value.get() len_new = len(new_leader_value) assert len_value + 1 == len_new assert new_leader_value[-1] == kwargs['default_multi'] @@ -625,16 +677,16 @@ def autocheck_append_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, else: follower_path += '.third' 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_: value = 'value' else: value = ['value'] leader_value.append(value) - assert len(cfg.config(confread).forcepermissive.option(pathread).value.get()) == len(new_leader_value) - cfg.forcepermissive.config(confwrite).option(pathread).value.set(leader_value) - assert cfg.config(confread).forcepermissive.option(pathread).value.get()[-1] == value + assert len(cfg_.forcepermissive.option(pathread).value.get()) == len(new_leader_value) + cfg2_.forcepermissive.option(pathread).value.set(leader_value) + assert cfg_.forcepermissive.option(pathread).value.get()[-1] == value @autocheck @@ -644,6 +696,14 @@ def autocheck_pop_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k if not isleader: 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 submulti_: values = ['value1', 'value2', 'value3', 'value4'] @@ -658,34 +718,34 @@ def autocheck_pop_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k else: a_follower += '.third' with warnings.catch_warnings(record=True) as w: - cfg.forcepermissive.config(confwrite).option(pathread).value.set(values) - cfg.forcepermissive.config(confwrite).option(a_follower, 1).value.set(follower_value) - cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] - assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True - cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == follower_value - assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is False - cfg.config(confread).forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi'] - assert cfg.config(confread).forcepermissive.option(a_follower, 2).owner.isdefault() is True - cfg.config(confread).forcepermissive.option(a_follower, 3).value.get() == kwargs['default_multi'] - assert cfg.config(confread).forcepermissive.option(a_follower, 3).owner.isdefault() is True + cfg_.forcepermissive.option(pathread).value.set(values) + cfg_.forcepermissive.option(a_follower, 1).value.set(follower_value) + cfg2_.forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] + assert cfg2_.forcepermissive.option(a_follower, 0).owner.isdefault() is True + cfg2_.forcepermissive.option(a_follower, 1).value.get() == follower_value + assert cfg2_.forcepermissive.option(a_follower, 1).owner.isdefault() is False + cfg2_.forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi'] + assert cfg2_.forcepermissive.option(a_follower, 2).owner.isdefault() is True + cfg2_.forcepermissive.option(a_follower, 3).value.get() == kwargs['default_multi'] + assert cfg2_.forcepermissive.option(a_follower, 3).owner.isdefault() is True # - cfg.forcepermissive.config(confwrite).option(pathread).value.pop(3) - cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] - assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True - cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == follower_value - assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is False - cfg.config(confread).forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi'] - assert cfg.config(confread).forcepermissive.option(a_follower, 2).owner.isdefault() is True + cfg_.forcepermissive.option(pathread).value.pop(3) + cfg2_.forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] + assert cfg2_.forcepermissive.option(a_follower, 0).owner.isdefault() is True + cfg2_.forcepermissive.option(a_follower, 1).value.get() == follower_value + assert cfg2_.forcepermissive.option(a_follower, 1).owner.isdefault() is False + cfg2_.forcepermissive.option(a_follower, 2).value.get() == kwargs['default_multi'] + assert cfg2_.forcepermissive.option(a_follower, 2).owner.isdefault() is True # - cfg.forcepermissive.config(confwrite).option(pathread).value.pop(0) - cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == follower_value - assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is False - cfg.config(confread).forcepermissive.option(a_follower, 1).value.get() == kwargs['default_multi'] - assert cfg.config(confread).forcepermissive.option(a_follower, 1).owner.isdefault() is True + cfg_.forcepermissive.option(pathread).value.pop(0) + cfg2_.forcepermissive.option(a_follower, 0).value.get() == follower_value + assert cfg2_.forcepermissive.option(a_follower, 0).owner.isdefault() is False + cfg2_.forcepermissive.option(a_follower, 1).value.get() == kwargs['default_multi'] + assert cfg2_.forcepermissive.option(a_follower, 1).owner.isdefault() is True # - cfg.forcepermissive.config(confwrite).option(pathread).value.pop(0) - cfg.config(confread).forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] - assert cfg.config(confread).forcepermissive.option(a_follower, 0).owner.isdefault() is True + cfg_.forcepermissive.option(pathread).value.pop(0) + cfg2_.forcepermissive.option(a_follower, 0).value.get() == kwargs['default_multi'] + assert cfg2_.forcepermissive.option(a_follower, 0).owner.isdefault() is True @autocheck @@ -697,12 +757,20 @@ def autocheck_reset_value_permissive(cfg, mcfg, pathread, pathwrite, confread, c with warnings.catch_warnings(record=True) as w: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): 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: cfg.forcepermissive.option(pathwrite, 1).value.reset() elif kwargs.get('permissive', False): 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: cfg.forcepermissive.option(pathwrite, 1).value.reset() #FIXME else: @@ -723,13 +791,21 @@ def autocheck_display(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwa return make_dict = kwargs['make_dict'] 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: - assert(cfg.config(confwrite).value.dict()) == make_dict + assert(cfg2_.value.dict()) == make_dict _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: - assert(cfg.config(confwrite).value.dict()) == make_dict_value + assert(cfg2_.value.dict()) == make_dict_value @autocheck @@ -749,7 +825,11 @@ def autocheck_property(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kw # set properties without permissive 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: _check_properties(cfg, mcfg, pathread, confread, kwargs, properties, properties) else: @@ -774,7 +854,11 @@ def autocheck_reset_property(cfg, mcfg, pathread, pathwrite, confread, confwrite _property_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs) # 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: _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() _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 if not isfollower: 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: - assert cfg.config(confread).option(pathread).owner.isdefault() is False + assert cfg2_.option(pathread).owner.isdefault() is False #FIXME else: # raises(PropertiesOptionError, "cfg.config(confwrite).option(pathread).owner.isdefault()") # raises(PropertiesOptionError, "cfg.config(confread).option(pathread).owner.isdefault()") else: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - assert cfg.config(confwrite).option(pathread, 0).owner.isdefault() is True - assert cfg.config(confwrite).option(pathread, 1).owner.isdefault() is False + assert cfg2_.option(pathread, 0).owner.isdefault() is True + assert cfg2_.option(pathread, 1).owner.isdefault() is False if confwrite != confread: - assert cfg.config(confread).option(pathread, 0).owner.isdefault() is True - assert cfg.config(confread).option(pathread, 1).owner.isdefault() is False + assert cfg_.option(pathread, 0).owner.isdefault() is True + assert cfg_.option(pathread, 1).owner.isdefault() is False #FIXME else: # raises(PropertiesOptionError, "cfg.config(confwrite).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): # 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 isfollower: - assert cfg.config(conf).forcepermissive.option(pathread).owner.isdefault() is False + assert cfg_.forcepermissive.option(pathread).owner.isdefault() is False else: - assert cfg.config(conf).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, 0).owner.isdefault() is True + assert cfg_.forcepermissive.option(pathread, 1).owner.isdefault() is False #FIXME else: # raises(PropertiesOptionError, "cfg.config(conf).forcepermissive.option(pathread).owner.isdefault()") do(confwrite) @@ -865,11 +959,15 @@ def autocheck_default_owner_with_value_permissive(cfg, mcfg, pathread, pathwrite @autocheck def autocheck_set_owner_no_value(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs): 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 isfollower: - raises(ConfigError, "cfg.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user')") + raises(ConfigError, "cfg_.option(pathwrite).owner.set('new_user')") else: - raises(ConfigError, "cfg.forcepermissive.option(pathwrite, 1).owner.set('new_user')") + raises(ConfigError, "cfg_.option(pathwrite, 1).owner.set('new_user')") @autocheck @@ -878,13 +976,17 @@ def autocheck_set_owner(cfg, mcfg, pathread, pathwrite, confread, confwrite, **k isfollower = cfg.unrestraint.option(pathread).option.isfollower() _set_value(cfg, pathwrite, confwrite, **kwargs) + if confwrite is not None: + cfg_ = cfg.config(confwrite) + else: + cfg_ = cfg # set owner without permissive if not isfollower: if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - cfg.config(confwrite).option(pathwrite).owner.set('new_user') - raises(ValueError, "cfg.config(confwrite).option(pathwrite).owner.set('default')") - raises(ValueError, "cfg.config(confwrite).option(pathwrite).owner.set('forced')") + cfg_.option(pathwrite).owner.set('new_user') + raises(ValueError, "cfg_.option(pathwrite).owner.set('default')") + raises(ValueError, "cfg_.option(pathwrite).owner.set('forced')") #FIXME else: # raises(PropertiesOptionError, "cfg.config(confwrite).option(pathwrite).owner.set('new_user')") else: @@ -903,11 +1005,15 @@ def autocheck_set_owner_permissive(cfg, mcfg, pathread, pathwrite, confread, con isfollower = cfg.unrestraint.option(pathread).option.isfollower() _set_value(cfg, pathwrite, confwrite, **kwargs) + if confwrite is not None: + cfg_ = cfg.forcepermissive.config(confwrite) + else: + cfg_ = cfg.forcepermissive # set owner with permissive if not kwargs.get('propertyerror', False): if not isfollower: - cfg.forcepermissive.config(confwrite).option(pathwrite).owner.set('new_user1') + cfg_.option(pathwrite).owner.set('new_user1') else: cfg.forcepermissive.option(pathwrite, 1).owner.set('new_user1') #FIXME else: @@ -961,9 +1067,17 @@ def autocheck_permissive(cfg, mcfg, pathread, pathwrite, confread, confwrite, ** """test permissive for hidden and disabled value """ # 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): - 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 # 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) # set permissive - cfg.unrestraint.config(confwrite).option(pathwrite).permissive.set(frozenset(['disabled'])) + cfg_.option(pathwrite).permissive.set(frozenset(['disabled'])) callback = kwargs['callback'] if callback: if pathread.endswith('val1') or pathread.endswith('val2'): call_path = pathread[:-4] + 'call' + pathread[-4:] else: 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? - assert cfg.unrestraint.config(confwrite).option(pathread).permissive.get() == frozenset(['disabled']) + assert cfg_.option(pathread).permissive.get() == frozenset(['disabled']) #if confwrite != confread: # 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 _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']: - 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 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): # 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'])) ckwargs['permissive'] = False _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) # only hidden - cfg.config(confread).unrestraint.option(pathwrite).permissive.set(frozenset(['hidden'])) + cfg2_.option(pathwrite).permissive.set(frozenset(['hidden'])) 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): _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['permissive'] = False _autocheck_default_value(cfg, pathread, confread, **ckwargs) # no permissive - cfg.config(confread).unrestraint.option(pathwrite).permissive.set(frozenset()) + cfg2_.option(pathwrite).permissive.set(frozenset()) 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): _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) @@ -1060,17 +1174,21 @@ def autocheck_find(cfg, mcfg, pathread, pathwrite, confread, confwrite, **kwargs option = _getoption(cfg.unrestraint.option(pathread)) def do(conf): - if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): - assert option == _getoption(cfg.config(conf).option.find(name, first=True)) - 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)) + if conf is not None: + cfg_ = cfg.config(conf) else: - raises(AttributeError, "cfg.config(conf).option.find(name, first=True)") - raises(AttributeError, "cfg.config(conf).forcepermissive.option.find(name, first=True)") - assert option == _getoption(cfg.config(conf).unrestraint.option.find(name, first=True)) - assert [option] == _getoptions(cfg.config(conf).unrestraint.option.find(name)) + cfg_ = cfg + if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False): + assert option == _getoption(cfg_.option.find(name, first=True)) + 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) if confread != confwrite: do(confwrite)