api: permissive => forcepermissive
api: add permissive object test api: permissive config: unwrap_from_path check properties for option, not only optiondescription option: _RegexpOption => RegexpOption
This commit is contained in:
@ -47,7 +47,7 @@ def autocheck_owner_without_value(api, path, **kwargs):
|
||||
"""check different value of owner when any value is set to this option
|
||||
"""
|
||||
try:
|
||||
isslave = api.permissive.option.isslave(path)
|
||||
isslave = api.forcepermissive.option.isslave(path)
|
||||
except:
|
||||
isslave = False
|
||||
# check if owner is a string "default"
|
||||
@ -61,14 +61,14 @@ def autocheck_owner_without_value(api, path, **kwargs):
|
||||
raises(APIError, "api.unrestraint.owner.get(path)")
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert api.permissive.owner.get(path) == 'default'
|
||||
assert api.forcepermissive.owner.get(path) == 'default'
|
||||
else:
|
||||
assert api.permissive.owner.get(path, 0) == 'default'
|
||||
assert api.forcepermissive.owner.get(path, 0) == 'default'
|
||||
else:
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.permissive.owner.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.owner.get(path)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.owner.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.owner.get(path, 0)")
|
||||
|
||||
# check if default owner
|
||||
raises(APIError, "api.unrestraint.owner.isdefault(path)")
|
||||
@ -77,9 +77,9 @@ def autocheck_owner_without_value(api, path, **kwargs):
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.owner.isdefault(path)")
|
||||
if not kwargs.get('propertyerror', False):
|
||||
assert api.permissive.owner.isdefault(path)
|
||||
assert api.forcepermissive.owner.isdefault(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.owner.isdefault(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.owner.isdefault(path)")
|
||||
|
||||
|
||||
@autocheck
|
||||
@ -88,11 +88,11 @@ def autocheck_value(api, path, **kwargs):
|
||||
"""
|
||||
# check if is a multi, a master or a slave
|
||||
if not kwargs.get('propertyerror', False):
|
||||
multi = api.permissive.option.ismulti(path)
|
||||
ismaster = api.permissive.option.ismaster(path)
|
||||
isslave = api.permissive.option.isslave(path)
|
||||
multi = api.forcepermissive.option.ismulti(path)
|
||||
ismaster = api.forcepermissive.option.ismaster(path)
|
||||
isslave = api.forcepermissive.option.isslave(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.option.ismulti(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.ismulti(path)")
|
||||
multi = api.unrestraint.option.ismulti(path)
|
||||
ismaster = api.unrestraint.option.ismaster(path)
|
||||
isslave = api.unrestraint.option.isslave(path)
|
||||
@ -122,9 +122,9 @@ def autocheck_value(api, path, **kwargs):
|
||||
raises(APIError, "api.unrestraint.value.get(path)")
|
||||
if not isslave:
|
||||
if not kwargs.get('propertyerror', False):
|
||||
assert api.permissive.value.get(path) == empty_value
|
||||
assert api.forcepermissive.value.get(path) == empty_value
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.value.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.get(path)")
|
||||
|
||||
# set a value without permissive
|
||||
# for master/slave should have an index and good length
|
||||
@ -158,17 +158,17 @@ def autocheck_value(api, path, **kwargs):
|
||||
elif kwargs.get('permissive', False):
|
||||
if isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
assert api.permissive.value.get(path, 0) == empty_value
|
||||
assert api.forcepermissive.value.get(path, 0) == empty_value
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
assert api.permissive.value.get(path) == empty_value
|
||||
assert api.forcepermissive.value.get(path) == empty_value
|
||||
else:
|
||||
if isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.permissive.value.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.get(path, 0)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
raises(PropertiesOptionError, "api.permissive.value.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.get(path)")
|
||||
|
||||
# set a value with permissive
|
||||
if ismaster:
|
||||
@ -179,30 +179,30 @@ def autocheck_value(api, path, **kwargs):
|
||||
raises(APIError, "api.unrestraint.value.set(path, second_value)")
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if ismaster:
|
||||
raises(IndexError, "api.permissive.value.set(path, 1, second_value[1])")
|
||||
api.permissive.value.append(path, second_value[1])
|
||||
raises(IndexError, "api.forcepermissive.value.set(path, 1, second_value[1])")
|
||||
api.forcepermissive.value.append(path, second_value[1])
|
||||
elif isslave:
|
||||
#FIXME
|
||||
raises(PropertiesOptionError, "api.permissive.value.append(path, second_value[1])")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.append(path, second_value[1])")
|
||||
api.value.set(path, 1, second_value[1])
|
||||
raise Exception('ca entre ici')
|
||||
else:
|
||||
api.value.set(path, second_value)
|
||||
elif kwargs.get('permissive', False):
|
||||
if ismaster:
|
||||
api.permissive.value.append(path, second_value[0])
|
||||
api.permissive.value.append(path, second_value[1])
|
||||
api.forcepermissive.value.append(path, second_value[0])
|
||||
api.forcepermissive.value.append(path, second_value[1])
|
||||
elif isslave:
|
||||
api.permissive.value.set(path, 1, second_value[1])
|
||||
api.forcepermissive.value.set(path, 1, second_value[1])
|
||||
else:
|
||||
api.permissive.value.set(path, first_value)
|
||||
api.forcepermissive.value.set(path, first_value)
|
||||
else:
|
||||
if ismaster:
|
||||
raises(PropertiesOptionError, "api.permissive.value.append(path, first_value[0])")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.append(path, first_value[0])")
|
||||
elif isslave:
|
||||
raises(PropertiesOptionError, "api.permissive.value.set(path, 0, first_value[0])")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.set(path, 0, first_value[0])")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.value.set(path, first_value)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.set(path, first_value)")
|
||||
|
||||
# get value after set value with permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
@ -214,32 +214,32 @@ def autocheck_value(api, path, **kwargs):
|
||||
elif kwargs.get('permissive', False):
|
||||
if ismaster:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
assert api.permissive.value.get(path) == second_value
|
||||
assert api.forcepermissive.value.get(path) == second_value
|
||||
elif isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.value.get(path, 1)")
|
||||
assert api.permissive.value.get(path, 1) == second_value[1]
|
||||
assert api.forcepermissive.value.get(path, 1) == second_value[1]
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
assert api.permissive.value.get(path) == first_value
|
||||
assert api.forcepermissive.value.get(path) == first_value
|
||||
else:
|
||||
if isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.permissive.value.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.get(path, 0)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
raises(PropertiesOptionError, "api.permissive.value.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.get(path)")
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_reset_value(api, path, **kwargs):
|
||||
# check if is a multi, a master or a slave
|
||||
if not kwargs.get('propertyerror', False):
|
||||
multi = api.permissive.option.ismulti(path)
|
||||
ismaster = api.permissive.option.ismaster(path)
|
||||
isslave = api.permissive.option.isslave(path)
|
||||
multi = api.forcepermissive.option.ismulti(path)
|
||||
ismaster = api.forcepermissive.option.ismaster(path)
|
||||
isslave = api.forcepermissive.option.isslave(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.option.ismulti(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.ismulti(path)")
|
||||
multi = api.unrestraint.option.ismulti(path)
|
||||
ismaster = api.unrestraint.option.ismaster(path)
|
||||
isslave = api.unrestraint.option.isslave(path)
|
||||
@ -278,28 +278,28 @@ def autocheck_reset_value(api, path, **kwargs):
|
||||
elif kwargs.get('permissive', False):
|
||||
if isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
assert api.permissive.value.get(path, 0) == empty_value
|
||||
assert api.permissive.value.get(path, 1) == second_value[1]
|
||||
assert api.forcepermissive.value.get(path, 0) == empty_value
|
||||
assert api.forcepermissive.value.get(path, 1) == second_value[1]
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
assert api.permissive.value.get(path) == first_value
|
||||
assert api.forcepermissive.value.get(path) == first_value
|
||||
|
||||
# reset value with permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
api.permissive.value.reset(path)
|
||||
api.forcepermissive.value.reset(path)
|
||||
else:
|
||||
api.permissive.value.reset(path, 1)
|
||||
api.forcepermissive.value.reset(path, 1)
|
||||
elif kwargs.get('permissive', False):
|
||||
if not isslave:
|
||||
api.permissive.value.reset(path)
|
||||
api.forcepermissive.value.reset(path)
|
||||
else:
|
||||
api.permissive.value.reset(path, 1)
|
||||
api.forcepermissive.value.reset(path, 1)
|
||||
else:
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.permissive.value.reset(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.reset(path)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.value.reset(path, 1)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.reset(path, 1)")
|
||||
|
||||
# get value after reset value with permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
@ -312,11 +312,11 @@ def autocheck_reset_value(api, path, **kwargs):
|
||||
if isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.value.get(path, 1)")
|
||||
assert api.permissive.value.get(path, 0) == empty_value
|
||||
assert api.permissive.value.get(path, 1) == empty_value
|
||||
assert api.forcepermissive.value.get(path, 0) == empty_value
|
||||
assert api.forcepermissive.value.get(path, 1) == empty_value
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
assert api.permissive.value.get(path) == empty_value
|
||||
assert api.forcepermissive.value.get(path) == empty_value
|
||||
|
||||
|
||||
@autocheck
|
||||
@ -332,11 +332,11 @@ def autocheck_property(api, path, **kwargs):
|
||||
"""
|
||||
# check if is a multi or a slave
|
||||
if not kwargs.get('propertyerror', False):
|
||||
multi = api.permissive.option.ismulti(path)
|
||||
isslave = api.permissive.option.isslave(path)
|
||||
multi = api.forcepermissive.option.ismulti(path)
|
||||
isslave = api.forcepermissive.option.isslave(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.option.ismulti(path)")
|
||||
raises(PropertiesOptionError, "api.permissive.option.isslave(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.ismulti(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.isslave(path)")
|
||||
multi = api.unrestraint.option.ismulti(path)
|
||||
isslave = api.unrestraint.option.isslave(path)
|
||||
|
||||
@ -370,15 +370,15 @@ def autocheck_property(api, path, **kwargs):
|
||||
raises(APIError, "api.unrestraint.property.get(path, 0)")
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert set(api.permissive.property.get(path)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(default_props)
|
||||
else:
|
||||
assert set(api.permissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path, 1)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(default_props)
|
||||
else:
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.permissive.property.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.property.get(path)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.property.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.property.get(path, 0)")
|
||||
|
||||
# set properties without permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
@ -389,54 +389,54 @@ def autocheck_property(api, path, **kwargs):
|
||||
# check properties after set without permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert set(api.property.get(path)) == set(properties)
|
||||
assert set(api.permissive.property.get(path)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(properties)
|
||||
elif kwargs.get('permissive', False):
|
||||
raises(PropertiesOptionError, "api.property.get(path)")
|
||||
if not isslave:
|
||||
assert set(api.permissive.property.get(path)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(default_props)
|
||||
else:
|
||||
assert set(api.permissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path, 1)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(default_props)
|
||||
else:
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.property.get(path)")
|
||||
raises(PropertiesOptionError, "api.permissive.property.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.property.get(path)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.property.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.permissive.property.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.property.get(path, 0)")
|
||||
|
||||
# set properties with permissive
|
||||
if not kwargs.get('propertyerror', False):
|
||||
api.permissive.property.set(path, properties)
|
||||
api.forcepermissive.property.set(path, properties)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.property.set(path, properties)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.property.set(path, properties)")
|
||||
|
||||
# check properties after set with permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert set(api.property.get(path)) == set(properties)
|
||||
assert set(api.permissive.property.get(path)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(properties)
|
||||
else:
|
||||
assert set(api.property.get(path, 0)) == set(properties)
|
||||
assert set(api.permissive.property.get(path, 0)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(properties)
|
||||
assert set(api.property.get(path, 1)) == set(properties)
|
||||
assert set(api.permissive.property.get(path, 1)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(properties)
|
||||
elif kwargs.get('permissive', False):
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.property.get(path)")
|
||||
assert set(api.permissive.property.get(path)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(properties)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.property.get(path, 0)")
|
||||
assert set(api.permissive.property.get(path, 0)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(properties)
|
||||
raises(PropertiesOptionError, "api.property.get(path, 1)")
|
||||
assert set(api.permissive.property.get(path, 1)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(properties)
|
||||
else:
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.property.get(path)")
|
||||
raises(PropertiesOptionError, "api.permissive.property.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.property.get(path)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.property.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.permissive.property.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.property.get(path, 0)")
|
||||
|
||||
|
||||
@autocheck
|
||||
@ -446,11 +446,11 @@ def autocheck_reset_property(api, path, **kwargs):
|
||||
|
||||
# check if is a multi or a slave
|
||||
if not kwargs.get('propertyerror', False):
|
||||
multi = api.permissive.option.ismulti(path)
|
||||
isslave = api.permissive.option.isslave(path)
|
||||
multi = api.forcepermissive.option.ismulti(path)
|
||||
isslave = api.forcepermissive.option.isslave(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.option.ismulti(path)")
|
||||
raises(PropertiesOptionError, "api.permissive.option.isslave(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.ismulti(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.isslave(path)")
|
||||
multi = api.unrestraint.option.ismulti(path)
|
||||
isslave = api.unrestraint.option.isslave(path)
|
||||
|
||||
@ -470,13 +470,13 @@ def autocheck_reset_property(api, path, **kwargs):
|
||||
# check properties
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
assert set(api.property.get(path)) == set(properties)
|
||||
assert set(api.permissive.property.get(path)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(properties)
|
||||
elif kwargs.get('permissive', False):
|
||||
if not isslave:
|
||||
assert set(api.permissive.property.get(path)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(properties)
|
||||
else:
|
||||
assert set(api.permissive.property.get(path, 0)) == set(properties)
|
||||
assert set(api.permissive.property.get(path, 1)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(properties)
|
||||
|
||||
# reset properties without permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
@ -488,44 +488,44 @@ def autocheck_reset_property(api, path, **kwargs):
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert set(api.property.get(path)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(default_props)
|
||||
else:
|
||||
assert set(api.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.property.get(path, 1)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path, 1)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(default_props)
|
||||
elif kwargs.get('permissive', False):
|
||||
if not isslave:
|
||||
assert set(api.permissive.property.get(path)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(properties)
|
||||
else:
|
||||
assert set(api.permissive.property.get(path, 0)) == set(properties)
|
||||
assert set(api.permissive.property.get(path, 1)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(properties)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(properties)
|
||||
|
||||
# reset properties with permissive
|
||||
raises(APIError, "api.unrestraint.property.set(path, properties)")
|
||||
raises(APIError, "api.unrestraint.property.reset(path)")
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
api.permissive.property.set(path, properties)
|
||||
api.permissive.property.reset(path)
|
||||
api.forcepermissive.property.set(path, properties)
|
||||
api.forcepermissive.property.reset(path)
|
||||
elif kwargs.get('permissive', False):
|
||||
api.permissive.property.reset(path)
|
||||
api.forcepermissive.property.reset(path)
|
||||
|
||||
# check properties
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert set(api.property.get(path)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(default_props)
|
||||
else:
|
||||
assert set(api.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.property.get(path, 1)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path, 1)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(default_props)
|
||||
elif kwargs.get('permissive', False):
|
||||
if not isslave:
|
||||
assert set(api.permissive.property.get(path)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path)) == set(default_props)
|
||||
else:
|
||||
assert set(api.permissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.permissive.property.get(path, 1)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 0)) == set(default_props)
|
||||
assert set(api.forcepermissive.property.get(path, 1)) == set(default_props)
|
||||
|
||||
|
||||
@autocheck
|
||||
@ -539,9 +539,9 @@ def autocheck_owner_with_value(api, path, **kwargs):
|
||||
"""
|
||||
# check if is a isslave
|
||||
if not kwargs.get('propertyerror', False):
|
||||
isslave = api.permissive.option.isslave(path)
|
||||
isslave = api.forcepermissive.option.isslave(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.option.isslave(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.isslave(path)")
|
||||
isslave = api.unrestraint.option.isslave(path)
|
||||
|
||||
# get owner without permissive
|
||||
@ -561,15 +561,15 @@ def autocheck_owner_with_value(api, path, **kwargs):
|
||||
# get owner with permissive
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert api.permissive.owner.get(path) == 'user'
|
||||
assert api.forcepermissive.owner.get(path) == 'user'
|
||||
else:
|
||||
assert api.permissive.owner.get(path, 0) == 'default'
|
||||
assert api.permissive.owner.get(path, 1) == 'user'
|
||||
assert api.forcepermissive.owner.get(path, 0) == 'default'
|
||||
assert api.forcepermissive.owner.get(path, 1) == 'user'
|
||||
else:
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.permissive.owner.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.owner.get(path)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.owner.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.owner.get(path, 0)")
|
||||
|
||||
# test if is default owner without permissive
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
@ -579,18 +579,18 @@ def autocheck_owner_with_value(api, path, **kwargs):
|
||||
|
||||
# test if is default owner with permissive
|
||||
if not kwargs.get('propertyerror', False):
|
||||
assert api.permissive.owner.isdefault(path) is False
|
||||
assert api.forcepermissive.owner.isdefault(path) is False
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.owner.isdefault(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.owner.isdefault(path)")
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_set_owner(api, path, **kwargs):
|
||||
# test set owner without permissive
|
||||
if not kwargs.get('propertyerror', False):
|
||||
isslave = api.permissive.option.isslave(path)
|
||||
isslave = api.forcepermissive.option.isslave(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.option.isslave(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.isslave(path)")
|
||||
isslave = False
|
||||
|
||||
# set owner without permissive
|
||||
@ -609,35 +609,35 @@ def autocheck_set_owner(api, path, **kwargs):
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert api.owner.get(path) == 'new_user'
|
||||
assert api.permissive.owner.get(path) == 'new_user'
|
||||
assert api.forcepermissive.owner.get(path) == 'new_user'
|
||||
else:
|
||||
assert api.owner.get(path, 1) == 'new_user'
|
||||
assert api.permissive.owner.get(path, 1) == 'new_user'
|
||||
assert api.forcepermissive.owner.get(path, 1) == 'new_user'
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert api.permissive.owner.get(path) == 'user'
|
||||
assert api.forcepermissive.owner.get(path) == 'user'
|
||||
else:
|
||||
assert api.permissive.owner.get(path, 1) == 'user'
|
||||
assert api.forcepermissive.owner.get(path, 1) == 'user'
|
||||
|
||||
# set owner with permissive
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
api.permissive.owner.set(path, 'new_user1')
|
||||
api.forcepermissive.owner.set(path, 'new_user1')
|
||||
else:
|
||||
api.permissive.owner.set(path, 1, 'new_user1')
|
||||
api.forcepermissive.owner.set(path, 1, 'new_user1')
|
||||
else:
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.permissive.owner.set(path, 'new_user1')")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.owner.set(path, 'new_user1')")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.permissive.owner.set(path, 1, 'new_user1')")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.owner.set(path, 1, 'new_user1')")
|
||||
|
||||
# get owner set with permissive
|
||||
if not kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
assert api.permissive.owner.get(path) == 'new_user1'
|
||||
assert api.forcepermissive.owner.get(path) == 'new_user1'
|
||||
else:
|
||||
assert api.permissive.owner.get(path, 0) == 'default'
|
||||
assert api.permissive.owner.get(path, 1) == 'new_user1'
|
||||
assert api.forcepermissive.owner.get(path, 0) == 'default'
|
||||
assert api.forcepermissive.owner.get(path, 1) == 'new_user1'
|
||||
|
||||
|
||||
@autocheck
|
||||
@ -645,24 +645,24 @@ def autocheck_option(api, path, **kwargs):
|
||||
expected_name = path.split('.')[-1]
|
||||
if not kwargs.get('permissive', False) and not kwargs.get('propertyerror', False):
|
||||
current_name = api.option.getname(path)
|
||||
assert current_name == api.permissive.option.getname(path)
|
||||
assert current_name == api.forcepermissive.option.getname(path)
|
||||
assert current_name == api.unrestraint.option.getname(path)
|
||||
doc = api.option.getdoc(path)
|
||||
assert doc == api.permissive.option.getdoc(path)
|
||||
assert doc == api.forcepermissive.option.getdoc(path)
|
||||
assert doc == api.unrestraint.option.getdoc(path)
|
||||
elif not kwargs.get('propertyerror', False):
|
||||
raises(PropertiesOptionError, "api.option.getname(path)")
|
||||
current_name = api.permissive.option.getname(path)
|
||||
current_name = api.forcepermissive.option.getname(path)
|
||||
assert current_name == api.unrestraint.option.getname(path)
|
||||
raises(PropertiesOptionError, "api.option.getdoc(path)")
|
||||
doc = api.permissive.option.getdoc(path)
|
||||
doc = api.forcepermissive.option.getdoc(path)
|
||||
assert doc == api.unrestraint.option.getdoc(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.option.getname(path)")
|
||||
raises(PropertiesOptionError, "api.permissive.option.getname(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.getname(path)")
|
||||
current_name = api.unrestraint.option.getname(path)
|
||||
raises(PropertiesOptionError, "api.option.getdoc(path)")
|
||||
raises(PropertiesOptionError, "api.permissive.option.getdoc(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.getdoc(path)")
|
||||
doc = api.unrestraint.option.getdoc(path)
|
||||
assert current_name == expected_name
|
||||
if expected_name.endswith('val1') or expected_name.endswith('val2'):
|
||||
@ -670,6 +670,85 @@ def autocheck_option(api, path, **kwargs):
|
||||
assert doc == "{}'s option".format(expected_name)
|
||||
|
||||
|
||||
@autocheck
|
||||
def autocheck_permissive(api, path, **kwargs):
|
||||
"""test permissive for hidden and disabled value
|
||||
"""
|
||||
# check if is a multi, a master or a slave
|
||||
if not kwargs.get('propertyerror', False):
|
||||
multi = api.forcepermissive.option.ismulti(path)
|
||||
ismaster = api.forcepermissive.option.ismaster(path)
|
||||
isslave = api.forcepermissive.option.isslave(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.forcepermissive.option.ismulti(path)")
|
||||
multi = api.unrestraint.option.ismulti(path)
|
||||
ismaster = api.unrestraint.option.ismaster(path)
|
||||
isslave = api.unrestraint.option.isslave(path)
|
||||
|
||||
# set default value (different if value is multi or not)
|
||||
if not multi:
|
||||
first_value = 'myvalue'
|
||||
second_value = 'myvalue1'
|
||||
else:
|
||||
first_value = ['myvalue']
|
||||
second_value = ['myvalue', 'myvalue1']
|
||||
if multi and not isslave:
|
||||
empty_value = []
|
||||
else:
|
||||
empty_value = None
|
||||
|
||||
# cannot access to hidden value without forcepermissive
|
||||
# and to disabled value (with forcepermissive too)
|
||||
if kwargs.get('propertyerror', False):
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.get(path)")
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
raises(PropertiesOptionError, "api.forcepermissive.value.get(path, 0)")
|
||||
elif kwargs.get('permissive', False):
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
api.forcepermissive.value.get(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
api.forcepermissive.value.get(path, 0)
|
||||
else:
|
||||
if not isslave:
|
||||
api.value.get(path)
|
||||
else:
|
||||
api.value.get(path, 0)
|
||||
assert api.permissive.get(path) == frozenset()
|
||||
api.permissive.set(path, ('disabled',))
|
||||
assert api.permissive.get(path) == frozenset(['disabled'])
|
||||
|
||||
# can access to disabled value
|
||||
if kwargs.get('permissive', False):
|
||||
if not isslave:
|
||||
raises(PropertiesOptionError, "api.value.get(path)")
|
||||
api.forcepermissive.value.get(path)
|
||||
else:
|
||||
raises(PropertiesOptionError, "api.value.get(path, 0)")
|
||||
api.forcepermissive.value.get(path, 0)
|
||||
else:
|
||||
if not isslave:
|
||||
api.value.get(path)
|
||||
else:
|
||||
api.value.get(path, 0)
|
||||
|
||||
api.permissive.set(path, ('disabled', 'hidden'))
|
||||
|
||||
# can access to value
|
||||
if not isslave:
|
||||
api.value.get(path)
|
||||
else:
|
||||
api.value.get(path, 0)
|
||||
assert api.permissive.get(path) == frozenset(['disabled', 'hidden'])
|
||||
|
||||
print('FIXME del !!!')
|
||||
|
||||
|
||||
|
||||
def check_all(api, path, multi, **kwargs):
|
||||
text = u' {} launch tests for {}'.format(ICON, path)
|
||||
if multi:
|
||||
|
@ -98,7 +98,7 @@ def test_cache_reset():
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
assert 'u1' in settings._p_.get_cached()
|
||||
assert 'u2' not in values._p_.get_cached()
|
||||
assert 'u2' in settings._p_.get_cached()
|
||||
assert 'u2' not in settings._p_.get_cached()
|
||||
#when remove a value
|
||||
c.u1
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
@ -107,7 +107,7 @@ def test_cache_reset():
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
assert 'u1' in settings._p_.get_cached()
|
||||
assert 'u2' not in values._p_.get_cached()
|
||||
assert 'u2' in settings._p_.get_cached()
|
||||
assert 'u2' not in settings._p_.get_cached()
|
||||
#when add/del property
|
||||
c.u1
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
@ -156,7 +156,7 @@ def test_cache_reset_multi():
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
assert 'u1' in settings._p_.get_cached()
|
||||
assert 'u3' not in values._p_.get_cached()
|
||||
assert 'u3' in settings._p_.get_cached()
|
||||
assert 'u3' not in settings._p_.get_cached()
|
||||
#when append value
|
||||
c.u1
|
||||
c.u3
|
||||
@ -168,7 +168,7 @@ def test_cache_reset_multi():
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
assert 'u1' in settings._p_.get_cached()
|
||||
assert 'u3' not in values._p_.get_cached()
|
||||
assert 'u3' in settings._p_.get_cached()
|
||||
assert 'u3' not in settings._p_.get_cached()
|
||||
#when pop value
|
||||
c.u1
|
||||
c.u3
|
||||
@ -180,7 +180,7 @@ def test_cache_reset_multi():
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
assert 'u1' in settings._p_.get_cached()
|
||||
assert 'u3' not in values._p_.get_cached()
|
||||
assert 'u3' in settings._p_.get_cached()
|
||||
assert 'u3' not in settings._p_.get_cached()
|
||||
#when remove a value
|
||||
c.u1
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
@ -189,7 +189,7 @@ def test_cache_reset_multi():
|
||||
assert 'u1' in values._p_.get_cached()
|
||||
assert 'u1' in settings._p_.get_cached()
|
||||
assert 'u3' not in values._p_.get_cached()
|
||||
assert 'u3' in settings._p_.get_cached()
|
||||
assert 'u3' not in settings._p_.get_cached()
|
||||
|
||||
|
||||
def test_reset_cache():
|
||||
@ -407,105 +407,83 @@ def test_cache_callback():
|
||||
cfg.cfgimpl_get_settings().remove('expire')
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val2': {None: (set(['mandatory']), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val4': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('val', None)},
|
||||
'val2': {None: ('val', None)},
|
||||
'val3': {None: ('yes', None)},
|
||||
'val4': {None: ('val', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
'val2': {None: ('val', None)},
|
||||
'val3': {None: ('yes', None)},
|
||||
'val4': {None: ('val', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
cfg.val1 = 'new'
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val3': {None: ('yes', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
'val5': {None: (['yes'], None)}}
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val2': {None: (set(['mandatory']), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val4': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('yes', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('yes', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
cfg.val3 = 'new2'
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val2': {None: (set(['mandatory']), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val4': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
'val2': {None: ('new', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val2': {None: (set(['mandatory']), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val4': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
cfg.val4 = 'new3'
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val2': {None: (set(['mandatory']), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val4': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)},
|
||||
# 'val4': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val2': {None: (set(['mandatory']), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val4': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)},
|
||||
# 'val4': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes'], None)}}
|
||||
cfg.val5.append('new4')
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val2': {None: (set(['mandatory']), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val4': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)},
|
||||
# 'val4': {None: (set([]), None)},
|
||||
# 'val5': {None: (set(['empty']), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)}}
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)}}
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val2': {None: (set(['mandatory']), None)},
|
||||
'val3': {None: (set([]), None)},
|
||||
'val4': {None: (set([]), None)},
|
||||
'val5': {None: (set(['empty']), None)}}
|
||||
#assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)},
|
||||
# 'val3': {None: (set([]), None)},
|
||||
# 'val4': {None: (set([]), None)},
|
||||
# 'val5': {None: (set(['empty']), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes', 'new4'], None)}}
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes', 'new4'], None)}}
|
||||
|
||||
|
||||
def test_cache_master_and_slaves_master():
|
||||
@ -519,34 +497,35 @@ def test_cache_master_and_slaves_master():
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
'val1.val2': {None: (set([]), None)}}
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
'val1.val2': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([], None)}, 'val1.val2': {None: ([], None)}}
|
||||
cfg.val1.val1.append()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)}}
|
||||
'val1': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
'val1.val2': {None: (set([]), None), 0: (set([]), None)}}
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
'val1.val2': {None: (set([]), None), 0: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
|
||||
'val1.val2': {None: ([None], None)}}
|
||||
cfg.val1.val1.append()
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
cfg.val1.val2[1] = 'oui'
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)}}
|
||||
'val1': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
'val1.val2': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}}
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
#FIXME voir pourquoi ce None ... soit c'est index soit ca ne l'ai pas ...
|
||||
'val1.val2': {None: (set([]), None), 0: (set([]), None), 1: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None, None], None)},
|
||||
'val1.val2': {None: ([None, 'oui'], None)}}
|
||||
'val1.val2': {None: ([None, 'oui'], None)}}
|
||||
|
||||
|
||||
def test_cache_master_callback():
|
||||
@ -560,21 +539,22 @@ def test_cache_master_callback():
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
'val1.val2': {None: (set([]), None)}}
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
'val1.val2': {None: (set([]), None)}}
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([], None)}, 'val1.val2': {None: ([], None)}}
|
||||
cfg.val1.val1.append()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)}}
|
||||
'val1': {None: (set([]), None)}}
|
||||
|
||||
assert cfg.cfgimpl_get_values()._p_.get_cached() == {}
|
||||
cfg.cfgimpl_get_values().force_cache()
|
||||
assert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'val1': {None: (set([]), None)},
|
||||
'val1.val1': {None: (set(['empty']), None)},
|
||||
'val1.val2': {None: (set([]), None), 0: (set([]), None)}}
|
||||
#assert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
|
||||
# 'val1.val2': {None: ([None], None), 0: (None, None)}}
|
||||
#FIXMEassert cfg.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
# 'val1': {None: (set([]), None)}}
|
||||
#FIXMEassert cfg.cfgimpl_get_values()._p_.get_cached() == {'val1.val1': {None: ([None], None)},
|
||||
# 'val1.val2': {None: ([None], None)}
|
||||
# }
|
||||
|
||||
|
||||
def test_cache_master_slave_different():
|
||||
b = IntOption('int', 'Test int option', default=[0], multi=True)
|
||||
@ -641,39 +621,37 @@ def test_cache_requires():
|
||||
assert c.cfgimpl_get_values()._p_.get_cached() == {}
|
||||
assert c.ip_address_service == None
|
||||
assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}}
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}}
|
||||
|
||||
assert c.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)}}
|
||||
c.cfgimpl_get_values().force_cache()
|
||||
assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}}
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}}
|
||||
|
||||
assert c.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: (None, None)},
|
||||
'activate_service': {None: (True, None)}}
|
||||
'activate_service': {None: (True, None)}}
|
||||
c.ip_address_service = '1.1.1.1'
|
||||
assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}}
|
||||
'activate_service': {None: (set([]), None)}}
|
||||
|
||||
assert c.cfgimpl_get_values()._p_.get_cached() == {'activate_service': {None: (True, None)}}
|
||||
c.cfgimpl_get_values().force_cache()
|
||||
assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}}
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}}
|
||||
|
||||
assert c.cfgimpl_get_values()._p_.get_cached() == {'ip_address_service': {None: ('1.1.1.1', None)},
|
||||
'activate_service': {None: (True, None)}}
|
||||
'activate_service': {None: (True, None)}}
|
||||
c.activate_service = False
|
||||
assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)}}
|
||||
assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)}}
|
||||
|
||||
assert c.cfgimpl_get_values()._p_.get_cached() == {}
|
||||
c.cfgimpl_get_values().force_cache()
|
||||
assert c.cfgimpl_get_settings()._p_.get_cached() == {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set(['disabled']), None)}}
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set(['disabled']), None)}}
|
||||
|
||||
assert c.cfgimpl_get_values()._p_.get_cached() == {'activate_service': {None: (False, None)}}
|
||||
|
||||
|
@ -190,12 +190,12 @@ def test_find_in_config():
|
||||
raises(AttributeError, "assert conf.find(byname='prop')")
|
||||
ret = conf.find(byname='prop', check_properties=False)
|
||||
assert len(ret) == 2
|
||||
_is_same_opt(ret[0], conf.unwrap_from_path('gc.gc2.prop'))
|
||||
_is_same_opt(ret[1], conf.unwrap_from_path('gc.prop'))
|
||||
_is_same_opt(ret[0], conf.cfgimpl_get_description().impl_get_opt_by_path('gc.gc2.prop'))
|
||||
_is_same_opt(ret[1], conf.unwrap_from_path('gc.prop', force_permissive=True))
|
||||
ret = conf.find(byname='prop', force_permissive=True)
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0], conf.unwrap_from_path('gc.prop'))
|
||||
_is_same_opt(conf.find_first(byname='prop', force_permissive=True), conf.unwrap_from_path('gc.prop'))
|
||||
_is_same_opt(ret[0], conf.unwrap_from_path('gc.prop', force_permissive=True))
|
||||
_is_same_opt(conf.find_first(byname='prop', force_permissive=True), conf.unwrap_from_path('gc.prop', force_permissive=True))
|
||||
#assert conf.find_first(byname='prop') == conf.unwrap_from_path('gc.prop')
|
||||
# combinaison of filters
|
||||
ret = conf.find(bytype=BoolOption, byname='dummy')
|
||||
@ -221,8 +221,8 @@ def test_find_in_config():
|
||||
raises(AttributeError, "conf.gc.find(byname='wantref').first()")
|
||||
ret = conf.gc.find(byname='prop', check_properties=False)
|
||||
assert len(ret) == 2
|
||||
_is_same_opt(ret[0], conf.unwrap_from_path('gc.gc2.prop'))
|
||||
_is_same_opt(ret[1], conf.unwrap_from_path('gc.prop'))
|
||||
_is_same_opt(ret[0], conf.cfgimpl_get_description().impl_get_opt_by_path('gc.gc2.prop'))
|
||||
_is_same_opt(ret[1], conf.unwrap_from_path('gc.prop', force_permissive=True))
|
||||
conf.read_only()
|
||||
ret = conf.gc.find(byname='prop')
|
||||
assert len(ret) == 1
|
||||
|
@ -153,7 +153,7 @@ def test_mod_dyndescription():
|
||||
cfg.od.dodval2.stval2 = 'no'
|
||||
assert cfg.od.dodval1.stval1 == 'yes'
|
||||
assert cfg.od.dodval2.stval2 == 'no'
|
||||
assert cfg.getowner(st) == owners.default
|
||||
#assert cfg.getowner(st) == owners.default
|
||||
assert cfg.getowner(stval1) == owner
|
||||
assert cfg.getowner(stval2) == owner
|
||||
|
||||
@ -195,7 +195,7 @@ def test_multi_dyndescription():
|
||||
cfg.od.dodval2.stval2 = ['no']
|
||||
assert cfg.od.dodval1.stval1 == ['yes']
|
||||
assert cfg.od.dodval2.stval2 == ['no']
|
||||
assert cfg.getowner(st) == owners.default
|
||||
#assert cfg.getowner(st) == owners.default
|
||||
assert cfg.getowner(stval1) == owner
|
||||
assert cfg.getowner(stval2) == owner
|
||||
cfg.od.dodval1.stval1.append('yes')
|
||||
@ -214,18 +214,18 @@ def test_prop_dyndescription():
|
||||
stval2 = cfg.unwrap_from_path('od.dodval2.stval2')
|
||||
dodval1 = cfg.unwrap_from_path('od.dodval1')
|
||||
dodval2 = cfg.unwrap_from_path('od.dodval2')
|
||||
assert str(cfg.cfgimpl_get_settings()[stval1]) in [str(['test']), str([u'test'])]
|
||||
assert str(cfg.cfgimpl_get_settings()[stval2]) in [str(['test']), str([u'test'])]
|
||||
assert set(cfg.cfgimpl_get_settings()[stval1].get()) == set(['test'])
|
||||
assert set(cfg.cfgimpl_get_settings()[stval2].get()) == set(['test'])
|
||||
cfg.cfgimpl_get_settings()[stval2].append('test2')
|
||||
assert str(cfg.cfgimpl_get_settings()[stval1]) in [str(['test']), str([u'test'])]
|
||||
assert str(cfg.cfgimpl_get_settings()[stval2]) in [str(['test', 'test2']), str([u'test', 'test2']), str(['test2', 'test'])]
|
||||
assert set(cfg.cfgimpl_get_settings()[stval1].get()) == set(['test'])
|
||||
assert set(cfg.cfgimpl_get_settings()[stval2].get()) == set(['test', 'test2'])
|
||||
cfg.cfgimpl_get_settings()[stval1].remove('test')
|
||||
assert str(cfg.cfgimpl_get_settings()[stval1]) == str([])
|
||||
#
|
||||
assert str(cfg.cfgimpl_get_settings()[dodval1]) == str([])
|
||||
assert str(cfg.cfgimpl_get_settings()[dodval2]) == str([])
|
||||
cfg.cfgimpl_get_settings()[dodval1].append('test1')
|
||||
assert str(cfg.cfgimpl_get_settings()[dodval1]) in [str(['test1']), str([u'test1'])]
|
||||
assert set(cfg.cfgimpl_get_settings()[dodval1].get()) == set(['test1'])
|
||||
assert str(cfg.cfgimpl_get_settings()[dodval2]) == str([])
|
||||
cfg.cfgimpl_get_settings()[dodval1].remove('test1')
|
||||
assert str(cfg.cfgimpl_get_settings()[dodval1]) == str([])
|
||||
@ -370,7 +370,7 @@ def test_mod_dyndescription_context():
|
||||
cfg.od.dodval2.stval2 = 'no'
|
||||
assert cfg.od.dodval1.stval1 == 'yes'
|
||||
assert cfg.od.dodval2.stval2 == 'no'
|
||||
assert cfg.getowner(st) == owners.default
|
||||
#assert cfg.getowner(st) == owners.default
|
||||
assert cfg.getowner(stval1) == owner
|
||||
assert cfg.getowner(stval2) == owner
|
||||
|
||||
@ -414,7 +414,7 @@ def test_multi_dyndescription_context():
|
||||
cfg.od.dodval2.stval2 = ['no']
|
||||
assert cfg.od.dodval1.stval1 == ['yes']
|
||||
assert cfg.od.dodval2.stval2 == ['no']
|
||||
assert cfg.getowner(st) == owners.default
|
||||
#assert cfg.getowner(st) == owners.default
|
||||
assert cfg.getowner(stval1) == owner
|
||||
assert cfg.getowner(stval2) == owner
|
||||
cfg.od.dodval1.stval1.append('yes')
|
||||
@ -533,99 +533,99 @@ def test_decrease_dyndescription_context():
|
||||
#FIXME
|
||||
# raises(AttributeError, "cfg.getowner(stval2)")
|
||||
raises(AttributeError, "cfg.unwrap_from_path('od.dodval2.stval2')")
|
||||
#
|
||||
#
|
||||
#def test_requires_dyndescription():
|
||||
# boolean = BoolOption('boolean', '', True)
|
||||
# st = StrOption('st', '', requires=[{'option': boolean, 'expected': False,
|
||||
# 'action': 'disabled'}])
|
||||
# dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
||||
# od = OptionDescription('od', '', [dod])
|
||||
# od2 = OptionDescription('od', '', [od, boolean])
|
||||
# cfg = Config(od2)
|
||||
# cfg.read_write()
|
||||
# assert cfg.od.dodval1.stval1 is None
|
||||
# assert cfg.od.dodval2.stval2 is None
|
||||
# #
|
||||
# cfg.boolean = False
|
||||
# props = []
|
||||
# try:
|
||||
# cfg.od.dodval1.stval1
|
||||
# except PropertiesOptionError as err:
|
||||
# props = err.proptype
|
||||
# assert props == ['disabled']
|
||||
# props = []
|
||||
# try:
|
||||
# cfg.od.dodval2.stval2
|
||||
# except PropertiesOptionError as err:
|
||||
# props = err.proptype
|
||||
# assert props == ['disabled']
|
||||
# #
|
||||
# cfg.boolean = True
|
||||
# assert cfg.od.dodval1.stval1 is None
|
||||
# assert cfg.od.dodval2.stval2 is None
|
||||
# #transitive
|
||||
# cfg.cfgimpl_get_settings()[boolean].append('disabled')
|
||||
# props = []
|
||||
# try:
|
||||
# cfg.od.dodval1.stval1
|
||||
# except PropertiesOptionError as err:
|
||||
# props = err.proptype
|
||||
# assert props == ['disabled']
|
||||
# props = []
|
||||
# try:
|
||||
# cfg.od.dodval2.stval2
|
||||
# except PropertiesOptionError as err:
|
||||
# props = err.proptype
|
||||
# assert props == ['disabled']
|
||||
|
||||
|
||||
def test_requires_dyndescription():
|
||||
boolean = BoolOption('boolean', '', True)
|
||||
st = StrOption('st', '', requires=[{'option': boolean, 'expected': False,
|
||||
'action': 'disabled'}])
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
||||
od = OptionDescription('od', '', [dod])
|
||||
od2 = OptionDescription('od', '', [od, boolean])
|
||||
cfg = Config(od2)
|
||||
cfg.read_write()
|
||||
assert cfg.od.dodval1.stval1 is None
|
||||
assert cfg.od.dodval2.stval2 is None
|
||||
#
|
||||
cfg.boolean = False
|
||||
props = []
|
||||
try:
|
||||
cfg.od.dodval1.stval1
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
props = []
|
||||
try:
|
||||
cfg.od.dodval2.stval2
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
#
|
||||
cfg.boolean = True
|
||||
assert cfg.od.dodval1.stval1 is None
|
||||
assert cfg.od.dodval2.stval2 is None
|
||||
#transitive
|
||||
cfg.cfgimpl_get_settings()[boolean].append('disabled')
|
||||
props = []
|
||||
try:
|
||||
cfg.od.dodval1.stval1
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
props = []
|
||||
try:
|
||||
cfg.od.dodval2.stval2
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
||||
|
||||
def test_requires_dyndescription2():
|
||||
boolean = BoolOption('boolean', '', True)
|
||||
st = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list,
|
||||
requires=[{'option': boolean, 'expected': False,
|
||||
'action': 'disabled'}])
|
||||
od = OptionDescription('od', '', [dod])
|
||||
od2 = OptionDescription('od', '', [od, boolean])
|
||||
cfg = Config(od2)
|
||||
cfg.read_write()
|
||||
assert cfg.od.dodval1.stval1 is None
|
||||
assert cfg.od.dodval2.stval2 is None
|
||||
#
|
||||
cfg.boolean = False
|
||||
props = []
|
||||
try:
|
||||
cfg.od.dodval1.stval1
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
props = []
|
||||
try:
|
||||
cfg.od.dodval2.stval2
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
#
|
||||
cfg.boolean = True
|
||||
assert cfg.od.dodval1.stval1 is None
|
||||
assert cfg.od.dodval2.stval2 is None
|
||||
#transitive
|
||||
cfg.cfgimpl_get_settings()[boolean].append('disabled')
|
||||
props = []
|
||||
try:
|
||||
cfg.od.dodval1.stval1
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
props = []
|
||||
try:
|
||||
cfg.od.dodval2.stval2
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert props == ['disabled']
|
||||
|
||||
|
||||
#def test_requires_dyndescription2():
|
||||
# boolean = BoolOption('boolean', '', True)
|
||||
# st = StrOption('st', '')
|
||||
# dod = DynOptionDescription('dod', '', [st], callback=return_list,
|
||||
# requires=[{'option': boolean, 'expected': False,
|
||||
# 'action': 'disabled'}])
|
||||
# od = OptionDescription('od', '', [dod])
|
||||
# od2 = OptionDescription('od', '', [od, boolean])
|
||||
# cfg = Config(od2)
|
||||
# cfg.read_write()
|
||||
# assert cfg.od.dodval1.stval1 is None
|
||||
# assert cfg.od.dodval2.stval2 is None
|
||||
# #
|
||||
# cfg.boolean = False
|
||||
# props = []
|
||||
# try:
|
||||
# cfg.od.dodval1.stval1
|
||||
# except PropertiesOptionError as err:
|
||||
# props = err.proptype
|
||||
# assert props == ['disabled']
|
||||
# props = []
|
||||
# try:
|
||||
# cfg.od.dodval2.stval2
|
||||
# except PropertiesOptionError as err:
|
||||
# props = err.proptype
|
||||
# assert props == ['disabled']
|
||||
# #
|
||||
# cfg.boolean = True
|
||||
# assert cfg.od.dodval1.stval1 is None
|
||||
# assert cfg.od.dodval2.stval2 is None
|
||||
# #transitive
|
||||
# cfg.cfgimpl_get_settings()[boolean].append('disabled')
|
||||
# props = []
|
||||
# try:
|
||||
# cfg.od.dodval1.stval1
|
||||
# except PropertiesOptionError as err:
|
||||
# props = err.proptype
|
||||
# assert props == ['disabled']
|
||||
# props = []
|
||||
# try:
|
||||
# cfg.od.dodval2.stval2
|
||||
# except PropertiesOptionError as err:
|
||||
# props = err.proptype
|
||||
# assert props == ['disabled']
|
||||
#
|
||||
#
|
||||
def test_validator_dyndescription():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '', validator=return_true, validator_params={'': ('yes',)}, default='val')
|
||||
@ -706,25 +706,25 @@ def test_information_dyndescription_context():
|
||||
assert dod.impl_get_information('testod') == 'val1'
|
||||
assert st.impl_get_information('testst') == 'val2'
|
||||
assert cfg.impl_get_information('testcfgod') == 'val3'
|
||||
|
||||
|
||||
def test_consistency_dyndescription():
|
||||
st = StrOption('st', '')
|
||||
st2 = StrOption('st2', '')
|
||||
dod = DynOptionDescription('dod', '', [st, st2], callback=return_list)
|
||||
od = OptionDescription('od', '', [dod])
|
||||
st.impl_add_consistency('not_equal', st2)
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
cfg.od.dodval1.stval1 = 'yes'
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1 = 'yes'")
|
||||
cfg.od.dodval2.stval2 = 'yes'
|
||||
raises(ValueError, "cfg.od.dodval2.st2val2 = 'yes'")
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1 = 'yes'")
|
||||
del(cfg.od.dodval2.stval2)
|
||||
raises(ValueError, "cfg.od.dodval1.st2val1 = 'yes'")
|
||||
cfg.od.dodval2.st2val2 = 'yes'
|
||||
raises(ValueError, "cfg.od.dodval2.stval2 = 'yes'")
|
||||
#
|
||||
#
|
||||
#def test_consistency_dyndescription():
|
||||
# st = StrOption('st', '')
|
||||
# st2 = StrOption('st2', '')
|
||||
# dod = DynOptionDescription('dod', '', [st, st2], callback=return_list)
|
||||
# od = OptionDescription('od', '', [dod])
|
||||
# st.impl_add_consistency('not_equal', st2)
|
||||
# od2 = OptionDescription('od', '', [od])
|
||||
# cfg = Config(od2)
|
||||
# cfg.od.dodval1.stval1 = 'yes'
|
||||
# raises(ValueError, "cfg.od.dodval1.st2val1 = 'yes'")
|
||||
# cfg.od.dodval2.stval2 = 'yes'
|
||||
# raises(ValueError, "cfg.od.dodval2.st2val2 = 'yes'")
|
||||
# raises(ValueError, "cfg.od.dodval1.st2val1 = 'yes'")
|
||||
# del(cfg.od.dodval2.stval2)
|
||||
# raises(ValueError, "cfg.od.dodval1.st2val1 = 'yes'")
|
||||
# cfg.od.dodval2.st2val2 = 'yes'
|
||||
# raises(ValueError, "cfg.od.dodval2.stval2 = 'yes'")
|
||||
|
||||
|
||||
def test_consistency_dyndescription_default():
|
||||
@ -893,197 +893,222 @@ def test_all_dyndescription():
|
||||
assert cfg.dodval2.urlval2 is None
|
||||
assert cfg.dodval2.usernameval2 is None
|
||||
assert cfg.dodval2.filenameval2 is None
|
||||
#
|
||||
#
|
||||
#def test_consistency_ip_netmask_dyndescription():
|
||||
# a = IPOption('a', '')
|
||||
# b = NetmaskOption('b', '')
|
||||
# dod = DynOptionDescription('dod', '', [a, b], callback=return_list)
|
||||
# b.impl_add_consistency('ip_netmask', a)
|
||||
# od = OptionDescription('od', '', [dod])
|
||||
# c = Config(od)
|
||||
# c.dodval1.aval1 = '192.168.1.1'
|
||||
# c.dodval1.bval1 = '255.255.255.0'
|
||||
# c.dodval2.aval2 = '192.168.1.2'
|
||||
# c.dodval2.bval2 = '255.255.255.255'
|
||||
## c.dodval2.bval2 = '255.255.255.0'
|
||||
#
|
||||
#
|
||||
#def test_consistency_ip_in_network_dyndescription():
|
||||
# a = NetworkOption('a', '')
|
||||
# b = NetmaskOption('b', '')
|
||||
# c = IPOption('c', '')
|
||||
# dod = DynOptionDescription('dod', '', [a, b, c], callback=return_list)
|
||||
# c.impl_add_consistency('in_network', a, b)
|
||||
# od = OptionDescription('od', '', [dod])
|
||||
# cfg = Config(od)
|
||||
# cfg.dodval1.aval1 = '192.168.1.0'
|
||||
# cfg.dodval1.bval1 = '255.255.255.0'
|
||||
# cfg.dodval1.cval1 = '192.168.1.1'
|
||||
|
||||
|
||||
def test_consistency_ip_netmask_dyndescription():
|
||||
a = IPOption('a', '')
|
||||
b = NetmaskOption('b', '')
|
||||
dod = DynOptionDescription('dod', '', [a, b], callback=return_list)
|
||||
b.impl_add_consistency('ip_netmask', a)
|
||||
od = OptionDescription('od', '', [dod])
|
||||
c = Config(od)
|
||||
c.dodval1.aval1 = '192.168.1.1'
|
||||
c.dodval1.bval1 = '255.255.255.0'
|
||||
c.dodval2.aval2 = '192.168.1.2'
|
||||
c.dodval2.bval2 = '255.255.255.255'
|
||||
c.dodval2.bval2 = '255.255.255.0'
|
||||
|
||||
|
||||
def test_consistency_ip_in_network_dyndescription():
|
||||
a = NetworkOption('a', '')
|
||||
b = NetmaskOption('b', '')
|
||||
c = IPOption('c', '')
|
||||
dod = DynOptionDescription('dod', '', [a, b, c], callback=return_list)
|
||||
c.impl_add_consistency('in_network', a, b)
|
||||
od = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od)
|
||||
cfg.dodval1.aval1 = '192.168.1.0'
|
||||
cfg.dodval1.bval1 = '255.255.255.0'
|
||||
cfg.dodval1.cval1 = '192.168.1.1'
|
||||
|
||||
|
||||
def test_masterslaves_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
owner = cfg.cfgimpl_get_settings().getowner()
|
||||
st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
assert cfg.make_dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []}
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owners.default
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
assert cfg.make_dict() == {'od.stval1.st1val1.st2val1': [None], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes']}
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == [None]
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == [None]
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st2val1 = ['no']
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == ['no']
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1, 0) == owner
|
||||
#def test_masterslaves_dyndescription():
|
||||
# st1 = StrOption('st1', "", multi=True)
|
||||
# st2 = StrOption('st2', "", multi=True)
|
||||
# stm = MasterSlaves('st1', '', [st1, st2])
|
||||
# #stm.impl_set_group_type(groups.master)
|
||||
# st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
# od = OptionDescription('od', '', [st])
|
||||
# od2 = OptionDescription('od', '', [od])
|
||||
# cfg = Config(od2)
|
||||
# print('--------------- 1')
|
||||
# owner = cfg.cfgimpl_get_settings().getowner()
|
||||
# print('--------------- 2')
|
||||
# st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
# print('--------------- 3')
|
||||
# st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
# print('--------------- 4')
|
||||
# st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
# print('--------------- 5')
|
||||
# st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
# print('--------------- 6')
|
||||
# assert cfg.make_dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []}
|
||||
# print('--------------- 7')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# print('--------------- 8')
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# print('--------------- 9')
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# print('--------------- 10')
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# print('--------------- 11')
|
||||
# assert cfg.getowner(st1val1) == owners.default
|
||||
# print('--------------- 12')
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# print('--------------- 13')
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# print('--------------- 14')
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1.pop(0)
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owner
|
||||
# print('--------------- 15')
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
# print('--------------- 16')
|
||||
# assert cfg.make_dict() == {'od.stval1.st1val1.st2val1': [None], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes']}
|
||||
# print('--------------- 17')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# print('--------------- 18')
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == [None]
|
||||
# print('--------------- 19')
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# print('--------------- 20')
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# print('--------------- 21')
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# print('--------------- 22')
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# print('--------------- 23')
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# print('--------------- 24')
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
cfg.od.stval1.st1val1.st2val1 = ['yes']
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st2val1, 0) == owner
|
||||
del(cfg.od.stval1.st1val1.st2val1)
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
# print('--------------- 25')
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == [None]
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
cfg.od.stval1.st1val1.st2val1 = ['yes']
|
||||
del(cfg.od.stval1.st1val1.st1val1)
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owners.default
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
|
||||
|
||||
def test_masterslaves_default_multi_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, default_multi='no')
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
owner = cfg.cfgimpl_get_settings().getowner()
|
||||
st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owners.default
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == ['no']
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
|
||||
|
||||
def test_masterslaves_submulti_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=submulti)
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
owner = cfg.cfgimpl_get_settings().getowner()
|
||||
st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owners.default
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == [[]]
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st2val1[0].append('no')
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == [['no']]
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1, 0) == owner
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st2val1 = ['no']
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == ['no']
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1, 0) == owner
|
||||
## assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1.pop(0)
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
## assert cfg.getowner(st2val1) == owner
|
||||
## assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
# cfg.od.stval1.st1val1.st2val1 = ['yes']
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st2val1, 0) == owner
|
||||
# del(cfg.od.stval1.st1val1.st2val1)
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
## assert cfg.getowner(st2val1) == owners.default
|
||||
## assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
# cfg.od.stval1.st1val1.st2val1 = ['yes']
|
||||
# del(cfg.od.stval1.st1val1.st1val1)
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owners.default
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
#
|
||||
#def test_masterslaves_default_multi_dyndescription():
|
||||
# st1 = StrOption('st1', "", multi=True)
|
||||
# st2 = StrOption('st2', "", multi=True, default_multi='no')
|
||||
# stm = MasterSlaves('st1', '', [st1, st2])
|
||||
# #stm.impl_set_group_type(groups.master)
|
||||
# st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
# od = OptionDescription('od', '', [st])
|
||||
# od2 = OptionDescription('od', '', [od])
|
||||
# cfg = Config(od2)
|
||||
# owner = cfg.cfgimpl_get_settings().getowner()
|
||||
# st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
# st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
# st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
# st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owners.default
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
# cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == ['no']
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
#
|
||||
#def test_masterslaves_submulti_dyndescription():
|
||||
# st1 = StrOption('st1', "", multi=True)
|
||||
# st2 = StrOption('st2', "", multi=submulti)
|
||||
# stm = MasterSlaves('st1', '', [st1, st2])
|
||||
# #stm.impl_set_group_type(groups.master)
|
||||
# st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
# od = OptionDescription('od', '', [st])
|
||||
# od2 = OptionDescription('od', '', [od])
|
||||
# cfg = Config(od2)
|
||||
# owner = cfg.cfgimpl_get_settings().getowner()
|
||||
# st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
# st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
# st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
# st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owners.default
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
# cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == [[]]
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st2val1[0].append('no')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == [['no']]
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1, 0) == owner
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
|
||||
|
||||
#def test_masterslaves_consistency_ip_dyndescription():
|
||||
@ -1127,187 +1152,187 @@ def test_masterslaves_submulti_dyndescription():
|
||||
# cfg.netval1.netval1 = ['192.168.1.0']
|
||||
# cfg.read_only()
|
||||
# raises(PropertiesOptionError, "cfg.netval1.netval1")
|
||||
|
||||
|
||||
def test_masterslaves_callback_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'value': ((st1, False),)})
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
owner = cfg.cfgimpl_get_settings().getowner()
|
||||
st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
assert cfg.make_dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []}
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owners.default
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
assert cfg.make_dict() == {'od.stval1.st1val1.st2val1': ['yes'], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes']}
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == ['yes']
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st2val1 = ['no']
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == ['no']
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1, 0) == owner
|
||||
#
|
||||
#
|
||||
#def test_masterslaves_callback_dyndescription():
|
||||
# st1 = StrOption('st1', "", multi=True)
|
||||
# st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'value': ((st1, False),)})
|
||||
# stm = MasterSlaves('st1', '', [st1, st2])
|
||||
# #stm.impl_set_group_type(groups.master)
|
||||
# st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
# od = OptionDescription('od', '', [st])
|
||||
# od2 = OptionDescription('od', '', [od])
|
||||
# cfg = Config(od2)
|
||||
# owner = cfg.cfgimpl_get_settings().getowner()
|
||||
# st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
# st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
# st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
# st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
# assert cfg.make_dict() == {'od.stval1.st1val1.st2val1': [], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': []}
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owners.default
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1.pop(0)
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owner
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
# assert cfg.make_dict() == {'od.stval1.st1val1.st2val1': ['yes'], 'od.stval2.st1val2.st2val2': [], 'od.stval2.st1val2.st1val2': [], 'od.stval1.st1val1.st1val1': ['yes']}
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == ['yes']
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
cfg.od.stval1.st1val1.st2val1 = ['yes']
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st2val1, 0) == owner
|
||||
del(cfg.od.stval1.st1val1.st2val1)
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
cfg.od.stval1.st1val1.st2val1 = ['yes']
|
||||
del(cfg.od.stval1.st1val1.st1val1)
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.getowner(st1val1) == owners.default
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st2val1 = []
|
||||
cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == ['yes']
|
||||
|
||||
|
||||
def test_masterslaves_callback_value_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'value': ('val',)})
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1[0] == 'val'
|
||||
assert cfg.od.stval1.st1val1.st2val1 == ['val']
|
||||
|
||||
|
||||
def test_masterslaves_callback_nomulti_dyndescription():
|
||||
v1 = StrOption('v1', '', "val")
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'': ((v1, False),)})
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od, v1])
|
||||
cfg = Config(od2)
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
assert cfg.od.stval1.st1val1.st2val1 == ['val']
|
||||
|
||||
|
||||
def test_masterslaves_callback_samegroup_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
st3 = StrOption('st3', "", multi=True, callback=return_dynval, callback_params={'': ((st2, False),)})
|
||||
stm = MasterSlaves('st1', '', [st1, st2, st3])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
cfg = Config(od2)
|
||||
owner = cfg.cfgimpl_get_settings().getowner()
|
||||
st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
st3val1 = cfg.unwrap_from_path('od.stval1.st1val1.st3val1')
|
||||
st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
st3val2 = cfg.unwrap_from_path('od.stval2.st1val2.st3val2')
|
||||
assert cfg.make_dict() == {'od.stval1.st1val1.st1val1': [],
|
||||
'od.stval1.st1val1.st2val1': [],
|
||||
'od.stval1.st1val1.st3val1': [],
|
||||
'od.stval2.st1val2.st1val2': [],
|
||||
'od.stval2.st1val2.st2val2': [],
|
||||
'od.stval2.st1val2.st3val2': []}
|
||||
assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
assert cfg.od.stval1.st1val1.st3val1 == []
|
||||
assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
assert cfg.od.stval2.st1val2.st3val2 == []
|
||||
assert cfg.getowner(st1val1) == owners.default
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
assert cfg.getowner(st3val1) == owners.default
|
||||
assert cfg.getowner(st3val2) == owners.default
|
||||
##
|
||||
cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
assert cfg.make_dict() == {'od.stval1.st1val1.st1val1': ['yes'],
|
||||
'od.stval1.st1val1.st2val1': [None],
|
||||
'od.stval1.st1val1.st3val1': [None],
|
||||
'od.stval2.st1val2.st1val2': [],
|
||||
'od.stval2.st1val2.st2val2': [],
|
||||
'od.stval2.st1val2.st3val2': []}
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
assert cfg.getowner(st2val1) == owners.default
|
||||
assert cfg.getowner(st2val2) == owners.default
|
||||
assert cfg.getowner(st3val1) == owners.default
|
||||
assert cfg.getowner(st3val2) == owners.default
|
||||
#
|
||||
cfg.od.stval1.st1val1.st2val1[0] = 'yes'
|
||||
assert cfg.make_dict() == {'od.stval1.st1val1.st1val1': ['yes'],
|
||||
'od.stval1.st1val1.st2val1': ['yes'],
|
||||
'od.stval1.st1val1.st3val1': ['yes'],
|
||||
'od.stval2.st1val2.st1val2': [],
|
||||
'od.stval2.st1val2.st2val2': [],
|
||||
'od.stval2.st1val2.st3val2': []}
|
||||
assert cfg.getowner(st1val1) == owner
|
||||
assert cfg.getowner(st2val1, 0) == owner
|
||||
assert cfg.getowner(st3val1, 0) == owners.default
|
||||
assert cfg.getowner(st1val2) == owners.default
|
||||
#assert cfg.getowner(st2val2) == owners.default
|
||||
#assert cfg.getowner(st3val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st2val1 = ['no']
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == ['no']
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1, 0) == owner
|
||||
## assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1.pop(0)
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
## assert cfg.getowner(st2val1) == owner
|
||||
## assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
# cfg.od.stval1.st1val1.st2val1 = ['yes']
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st2val1, 0) == owner
|
||||
# del(cfg.od.stval1.st1val1.st2val1)
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
# cfg.od.stval1.st1val1.st2val1 = ['yes']
|
||||
# del(cfg.od.stval1.st1val1.st1val1)
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.getowner(st1val1) == owners.default
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st2val1 = []
|
||||
# cfg.od.stval1.st1val1.st1val1 = ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == ['yes']
|
||||
#
|
||||
#
|
||||
#def test_masterslaves_callback_value_dyndescription():
|
||||
# st1 = StrOption('st1', "", multi=True)
|
||||
# st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'value': ('val',)})
|
||||
# stm = MasterSlaves('st1', '', [st1, st2])
|
||||
# #stm.impl_set_group_type(groups.master)
|
||||
# st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
# od = OptionDescription('od', '', [st])
|
||||
# od2 = OptionDescription('od', '', [od])
|
||||
# cfg = Config(od2)
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1[0] == 'val'
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == ['val']
|
||||
#
|
||||
#
|
||||
#def test_masterslaves_callback_nomulti_dyndescription():
|
||||
# v1 = StrOption('v1', '', "val")
|
||||
# st1 = StrOption('st1', "", multi=True)
|
||||
# st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'': ((v1, False),)})
|
||||
# stm = MasterSlaves('st1', '', [st1, st2])
|
||||
# #stm.impl_set_group_type(groups.master)
|
||||
# st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
# od = OptionDescription('od', '', [st])
|
||||
# od2 = OptionDescription('od', '', [od, v1])
|
||||
# cfg = Config(od2)
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == ['yes']
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == ['val']
|
||||
#
|
||||
#
|
||||
#def test_masterslaves_callback_samegroup_dyndescription():
|
||||
# st1 = StrOption('st1', "", multi=True)
|
||||
# st2 = StrOption('st2', "", multi=True)
|
||||
# st3 = StrOption('st3', "", multi=True, callback=return_dynval, callback_params={'': ((st2, False),)})
|
||||
# stm = MasterSlaves('st1', '', [st1, st2, st3])
|
||||
# #stm.impl_set_group_type(groups.master)
|
||||
# st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
# od = OptionDescription('od', '', [st])
|
||||
# od2 = OptionDescription('od', '', [od])
|
||||
# cfg = Config(od2)
|
||||
# owner = cfg.cfgimpl_get_settings().getowner()
|
||||
# st1val1 = cfg.unwrap_from_path('od.stval1.st1val1.st1val1')
|
||||
# st2val1 = cfg.unwrap_from_path('od.stval1.st1val1.st2val1')
|
||||
# st3val1 = cfg.unwrap_from_path('od.stval1.st1val1.st3val1')
|
||||
# st1val2 = cfg.unwrap_from_path('od.stval2.st1val2.st1val2')
|
||||
# st2val2 = cfg.unwrap_from_path('od.stval2.st1val2.st2val2')
|
||||
# st3val2 = cfg.unwrap_from_path('od.stval2.st1val2.st3val2')
|
||||
# assert cfg.make_dict() == {'od.stval1.st1val1.st1val1': [],
|
||||
# 'od.stval1.st1val1.st2val1': [],
|
||||
# 'od.stval1.st1val1.st3val1': [],
|
||||
# 'od.stval2.st1val2.st1val2': [],
|
||||
# 'od.stval2.st1val2.st2val2': [],
|
||||
# 'od.stval2.st1val2.st3val2': []}
|
||||
# assert cfg.od.stval1.st1val1.st1val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st2val1 == []
|
||||
# assert cfg.od.stval1.st1val1.st3val1 == []
|
||||
# assert cfg.od.stval2.st1val2.st1val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st2val2 == []
|
||||
# assert cfg.od.stval2.st1val2.st3val2 == []
|
||||
# assert cfg.getowner(st1val1) == owners.default
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
# assert cfg.getowner(st3val1) == owners.default
|
||||
# assert cfg.getowner(st3val2) == owners.default
|
||||
# ##
|
||||
# cfg.od.stval1.st1val1.st1val1.append('yes')
|
||||
# assert cfg.make_dict() == {'od.stval1.st1val1.st1val1': ['yes'],
|
||||
# 'od.stval1.st1val1.st2val1': [None],
|
||||
# 'od.stval1.st1val1.st3val1': [None],
|
||||
# 'od.stval2.st1val2.st1val2': [],
|
||||
# 'od.stval2.st1val2.st2val2': [],
|
||||
# 'od.stval2.st1val2.st3val2': []}
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# assert cfg.getowner(st2val1) == owners.default
|
||||
# assert cfg.getowner(st2val2) == owners.default
|
||||
# assert cfg.getowner(st3val1) == owners.default
|
||||
# assert cfg.getowner(st3val2) == owners.default
|
||||
# #
|
||||
# cfg.od.stval1.st1val1.st2val1[0] = 'yes'
|
||||
# assert cfg.make_dict() == {'od.stval1.st1val1.st1val1': ['yes'],
|
||||
# 'od.stval1.st1val1.st2val1': ['yes'],
|
||||
# 'od.stval1.st1val1.st3val1': ['yes'],
|
||||
# 'od.stval2.st1val2.st1val2': [],
|
||||
# 'od.stval2.st1val2.st2val2': [],
|
||||
# 'od.stval2.st1val2.st3val2': []}
|
||||
# assert cfg.getowner(st1val1) == owner
|
||||
# assert cfg.getowner(st2val1, 0) == owner
|
||||
# assert cfg.getowner(st3val1, 0) == owners.default
|
||||
# assert cfg.getowner(st1val2) == owners.default
|
||||
# #assert cfg.getowner(st2val2) == owners.default
|
||||
# #assert cfg.getowner(st3val2) == owners.default
|
||||
|
||||
|
||||
def test_invalid_conflict_dyndescription():
|
||||
|
@ -32,11 +32,14 @@ def make_description():
|
||||
return od2
|
||||
|
||||
|
||||
idx = 0
|
||||
def make_metaconfig():
|
||||
global idx
|
||||
idx += 1
|
||||
od2 = make_description()
|
||||
conf1 = Config(od2, session_id='conf3')
|
||||
conf2 = Config(od2, session_id='conf4')
|
||||
meta = MetaConfig([conf1, conf2], session_id='meta')
|
||||
conf1 = Config(od2, session_id='conf3_{}'.format(idx))
|
||||
conf2 = Config(od2, session_id='conf4_{}'.format(idx))
|
||||
meta = MetaConfig([conf1, conf2], session_id='meta_{}'.format(idx))
|
||||
meta.read_write()
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
return meta
|
||||
@ -44,7 +47,6 @@ def make_metaconfig():
|
||||
|
||||
#FIXME ne pas mettre 2 meta dans une config
|
||||
#FIXME ne pas mettre 2 OD differents dans un meta
|
||||
#FIXME serialization
|
||||
def test_none():
|
||||
meta = make_metaconfig()
|
||||
conf1, conf2 = meta.cfgimpl_get_children()
|
||||
@ -72,6 +74,8 @@ def test_none():
|
||||
del(conf1.od1.i3)
|
||||
assert conf1.od1.i3 is conf2.od1.i3 is None
|
||||
assert conf1.getowner(conf1.unwrap_from_path('od1.i3')) is conf2.getowner(conf2.unwrap_from_path('od1.i3')) is owners.default
|
||||
del(conf1)
|
||||
del(conf2)
|
||||
|
||||
|
||||
def test_default():
|
||||
@ -132,8 +136,8 @@ def test_group_error():
|
||||
def test_meta_meta():
|
||||
meta1 = make_metaconfig()
|
||||
meta2 = MetaConfig([meta1])
|
||||
assert str(meta1) == """(conf3)
|
||||
(conf4)
|
||||
assert str(meta1) == """(conf3_5)
|
||||
(conf4_5)
|
||||
[od1]"""
|
||||
meta2.cfgimpl_get_settings().setowner(owners.meta)
|
||||
conf1, conf2 = meta1.cfgimpl_get_children()
|
||||
@ -184,7 +188,7 @@ def test_meta_new_config():
|
||||
def test_meta_new_config_wrong_name():
|
||||
meta = make_metaconfig()
|
||||
assert len(meta.cfgimpl_get_children()) == 2
|
||||
raises(ConflictError, "meta.new_config('conf4')")
|
||||
raises(ConflictError, "meta.new_config('conf4_7')")
|
||||
assert len(meta.cfgimpl_get_children()) == 2
|
||||
|
||||
|
||||
@ -319,21 +323,21 @@ def test_meta_master_slaves_value2():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2], session_id="meta")
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.8']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
del(meta.conf1.ip_admin_eth0)
|
||||
assert meta.conf1.netmask_admin_eth0 == []
|
||||
conf1 = Config(interface1, session_id='mconf1')
|
||||
conf2 = Config(interface1, session_id='mconf2')
|
||||
meta = MetaConfig([conf1, conf2], session_id="mmeta")
|
||||
meta.mconf1.ip_admin_eth0 = ['192.168.1.8']
|
||||
assert meta.mconf1.netmask_admin_eth0 == [None]
|
||||
del(meta.mconf1.ip_admin_eth0)
|
||||
assert meta.mconf1.netmask_admin_eth0 == []
|
||||
meta.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
assert meta.mconf1.netmask_admin_eth0 == [None]
|
||||
meta.netmask_admin_eth0 = ['255.255.255.0']
|
||||
assert meta.conf1.netmask_admin_eth0 == ['255.255.255.0']
|
||||
assert meta.mconf1.netmask_admin_eth0 == ['255.255.255.0']
|
||||
meta.netmask_admin_eth0 = ['255.255.0.0']
|
||||
assert meta.conf1.netmask_admin_eth0 == ['255.255.0.0']
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
assert meta.mconf1.netmask_admin_eth0 == ['255.255.0.0']
|
||||
meta.mconf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.mconf1.netmask_admin_eth0 == [None]
|
||||
|
||||
|
||||
def test_meta_master_slaves_value_default():
|
||||
@ -341,18 +345,18 @@ def test_meta_master_slaves_value_default():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf1 = Config(interface1, session_id='nconf1')
|
||||
conf2 = Config(interface1, session_id='nconf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
assert meta.nconf1.netmask_admin_eth0 == [None]
|
||||
meta.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
assert meta.nconf1.netmask_admin_eth0 == [None]
|
||||
meta.netmask_admin_eth0 = ['255.255.255.0']
|
||||
assert meta.conf1.netmask_admin_eth0 == ['255.255.255.0']
|
||||
assert meta.nconf1.netmask_admin_eth0 == ['255.255.255.0']
|
||||
meta.netmask_admin_eth0 = ['255.255.0.0']
|
||||
assert meta.conf1.netmask_admin_eth0 == ['255.255.0.0']
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
assert meta.nconf1.netmask_admin_eth0 == ['255.255.0.0']
|
||||
meta.nconf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.nconf1.netmask_admin_eth0 == [None]
|
||||
del(conf1)
|
||||
del(conf2)
|
||||
|
||||
@ -362,30 +366,30 @@ def test_meta_master_slaves_owners():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf1 = Config(interface1, session_id='sconf1')
|
||||
conf2 = Config(interface1, session_id='sconf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
assert meta.conf1.getowner(ip_admin_eth0) == owners.default
|
||||
assert meta.conf1.getowner(netmask_admin_eth0) == owners.default
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.getowner(ip_admin_eth0) == owners.user
|
||||
assert meta.conf1.getowner(netmask_admin_eth0) == owners.default
|
||||
del(meta.conf1.ip_admin_eth0)
|
||||
assert meta.conf1.getowner(ip_admin_eth0) == owners.default
|
||||
assert meta.conf1.getowner(netmask_admin_eth0) == owners.default
|
||||
assert meta.sconf1.getowner(ip_admin_eth0) == owners.default
|
||||
assert meta.sconf1.getowner(netmask_admin_eth0) == owners.default
|
||||
meta.sconf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.sconf1.getowner(ip_admin_eth0) == owners.user
|
||||
assert meta.sconf1.getowner(netmask_admin_eth0) == owners.default
|
||||
del(meta.sconf1.ip_admin_eth0)
|
||||
assert meta.sconf1.getowner(ip_admin_eth0) == owners.default
|
||||
assert meta.sconf1.getowner(netmask_admin_eth0) == owners.default
|
||||
meta.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.getowner(ip_admin_eth0) == owners.meta
|
||||
assert meta.conf1.getowner(netmask_admin_eth0) == owners.default
|
||||
assert meta.sconf1.getowner(ip_admin_eth0) == owners.meta
|
||||
assert meta.sconf1.getowner(netmask_admin_eth0) == owners.default
|
||||
meta.netmask_admin_eth0 = ['255.255.255.0']
|
||||
assert meta.conf1.getowner(ip_admin_eth0) == owners.meta
|
||||
assert meta.conf1.getowner(netmask_admin_eth0, 0) == owners.meta
|
||||
assert meta.sconf1.getowner(ip_admin_eth0) == owners.meta
|
||||
assert meta.sconf1.getowner(netmask_admin_eth0, 0) == owners.meta
|
||||
meta.netmask_admin_eth0 = ['255.255.0.0']
|
||||
assert meta.conf1.getowner(ip_admin_eth0) == owners.meta
|
||||
assert meta.conf1.getowner(netmask_admin_eth0, 0) == owners.meta
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.getowner(ip_admin_eth0) == owners.user
|
||||
assert meta.conf1.getowner(netmask_admin_eth0, 0) == owners.default
|
||||
assert meta.sconf1.getowner(ip_admin_eth0) == owners.meta
|
||||
assert meta.sconf1.getowner(netmask_admin_eth0, 0) == owners.meta
|
||||
meta.sconf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.sconf1.getowner(ip_admin_eth0) == owners.user
|
||||
assert meta.sconf1.getowner(netmask_admin_eth0, 0) == owners.default
|
||||
|
||||
|
||||
def test_meta_force_default():
|
||||
@ -393,35 +397,35 @@ def test_meta_force_default():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1 = Config(interface1, session_id='oconf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2 = Config(interface1, session_id='oconf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
assert meta.ip_admin_eth0 == []
|
||||
assert meta.conf1.ip_admin_eth0 == []
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert meta.oconf1.ip_admin_eth0 == []
|
||||
assert meta.oconf2.ip_admin_eth0 == []
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.1'])
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.1']
|
||||
errors = meta.conf1.ip_admin_eth0 = ['192.168.1.2']
|
||||
assert meta.oconf1.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.oconf2.ip_admin_eth0 == ['192.168.1.1']
|
||||
errors = meta.oconf1.ip_admin_eth0 = ['192.168.1.2']
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.2']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.1']
|
||||
assert meta.oconf1.ip_admin_eth0 == ['192.168.1.2']
|
||||
assert meta.oconf2.ip_admin_eth0 == ['192.168.1.1']
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.3'])
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.2']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.oconf1.ip_admin_eth0 == ['192.168.1.2']
|
||||
assert meta.oconf2.ip_admin_eth0 == ['192.168.1.3']
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_default=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.oconf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.oconf2.ip_admin_eth0 == ['192.168.1.4']
|
||||
|
||||
|
||||
def test_meta_force_dont_change_value():
|
||||
@ -429,26 +433,26 @@ def test_meta_force_dont_change_value():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1 = Config(interface1, session_id='pconf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2 = Config(interface1, session_id='pconf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
assert meta.ip_admin_eth0 == []
|
||||
assert meta.conf1.ip_admin_eth0 == []
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert meta.pconf1.ip_admin_eth0 == []
|
||||
assert meta.pconf2.ip_admin_eth0 == []
|
||||
meta.pconf1.ip_admin_eth0 = ['192.168.1.4']
|
||||
assert meta.pconf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.pconf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.default
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_dont_change_value=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert meta.pconf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.pconf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.user
|
||||
|
||||
@ -502,41 +506,41 @@ def test_meta_force_default_if_same_and_dont_change():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1 = Config(interface1, session_id='qconf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2 = Config(interface1, session_id='qconf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
#
|
||||
assert meta.ip_admin_eth0 == []
|
||||
assert meta.conf1.ip_admin_eth0 == []
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert meta.qconf1.ip_admin_eth0 == []
|
||||
assert meta.qconf2.ip_admin_eth0 == []
|
||||
#
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
meta.qconf1.ip_admin_eth0 = ['192.168.1.4']
|
||||
assert meta.qconf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.qconf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.default
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True, force_dont_change_value=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert meta.qconf1.ip_admin_eth0 == ['192.168.1.4']
|
||||
assert meta.qconf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.meta
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.user
|
||||
#
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.3']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
meta.qconf1.ip_admin_eth0 = ['192.168.1.3']
|
||||
assert meta.qconf1.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.qconf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.user
|
||||
errors = meta.set_value('ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True, force_dont_change_value=True)
|
||||
assert len(errors) == 0
|
||||
assert meta.ip_admin_eth0 == ['192.168.1.5']
|
||||
assert meta.conf1.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.conf2.ip_admin_eth0 == []
|
||||
assert meta.qconf1.ip_admin_eth0 == ['192.168.1.3']
|
||||
assert meta.qconf2.ip_admin_eth0 == []
|
||||
assert conf1.getowner(ip_admin_eth0) is owners.user
|
||||
assert conf2.getowner(ip_admin_eth0) is owners.user
|
||||
|
||||
@ -546,9 +550,9 @@ def test_meta_force_default_and_dont_change():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1 = Config(interface1, session_id='rconf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2 = Config(interface1, session_id='rconf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -562,9 +566,9 @@ def test_meta_properties_meta():
|
||||
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1 = Config(interface1, session_id='sconf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2 = Config(interface1, session_id='sconf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -619,38 +623,38 @@ def test_meta_callback_slave():
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
cfg = Config(maconfig, session_id='cfg')
|
||||
cfg = Config(maconfig, session_id='cfg1')
|
||||
meta = MetaConfig([cfg])
|
||||
meta.read_write()
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.cfg.val = 'val1'
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||
del(meta.cfg.val)
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.cfg1.val = 'val1'
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||
del(meta.cfg1.val)
|
||||
meta.val = 'val1'
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
||||
del(meta.val)
|
||||
meta.cfg.val1.val2 = ['val2']
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
del(meta.cfg.val1.val2)
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.cfg1.val1.val2 = ['val2']
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
del(meta.cfg1.val1.val2)
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.val1.val2 = ['val2']
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.cfg.val1.val3 = ['val6']
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.cfg1.val1.val3 = ['val6']
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
||||
del(meta.val1.val2)
|
||||
del(meta.cfg.val1.val3)
|
||||
meta.cfg.val1.val1 = ['val3']
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
del(meta.cfg.val1.val1)
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
del(meta.cfg1.val1.val3)
|
||||
meta.cfg1.val1.val1 = ['val3']
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
del(meta.cfg1.val1.val1)
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
meta.val1.val1 = ['val3']
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
meta.cfg.val1.val2 = ['val2']
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
meta.cfg.val1.val1.append('rah')
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
meta.cfg1.val1.val2 = ['val2']
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
||||
meta.cfg1.val1.val1.append('rah')
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||
meta.val1.val1 = ['val4']
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||
assert meta.cfg1.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||
|
||||
|
||||
def test_meta_properties_meta_set_value():
|
||||
|
@ -45,8 +45,8 @@ def test_is_hidden():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
dummy = config.unwrap_from_path('gc.dummy')
|
||||
config.read_write()
|
||||
assert not 'frozen' in setting[dummy]
|
||||
# setattr
|
||||
raises(PropertiesOptionError, "config.gc.dummy == False")
|
||||
@ -60,7 +60,7 @@ def test_group_is_hidden():
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
gc = config.unwrap_from_path('gc')
|
||||
config.unwrap_from_path('gc.dummy')
|
||||
#config.unwrap_from_path('gc.dummy')
|
||||
setting[gc].append('hidden')
|
||||
raises(PropertiesOptionError, "config.gc.dummy")
|
||||
assert 'hidden' in setting[gc]
|
||||
@ -83,7 +83,7 @@ def test_extend_properties():
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
gc = config.unwrap_from_path('gc')
|
||||
config.unwrap_from_path('gc.dummy')
|
||||
#config.unwrap_from_path('gc.dummy')
|
||||
setting[gc].extend(['hidden', 'user_defined_property'])
|
||||
assert 'hidden' in setting[gc]
|
||||
assert 'user_defined_property' in setting[gc]
|
||||
@ -113,8 +113,8 @@ def test_global_show():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
dummy = config.unwrap_from_path('gc.dummy')
|
||||
config.read_write()
|
||||
setting[dummy].append('hidden')
|
||||
assert 'hidden' in setting[dummy]
|
||||
raises(PropertiesOptionError, "config.gc.dummy == False")
|
||||
|
@ -701,9 +701,9 @@ def test_multi_submulti_meta():
|
||||
def test_multi_submulti_meta_no_cache():
|
||||
multi = StrOption('multi', '', multi=submulti)
|
||||
od = OptionDescription('od', '', [multi])
|
||||
conf1 = Config(od, session_id='conf1')
|
||||
conf1 = Config(od, session_id='conf1_1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(od, session_id='conf2')
|
||||
conf2 = Config(od, session_id='conf2_1')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
|
Reference in New Issue
Block a user