corrections in dict and todict
This commit is contained in:
@ -1,12 +1,14 @@
|
||||
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
||||
from tiramisu import ChoiceOption, StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
def get_description():
|
||||
"""generate description for this test
|
||||
"""
|
||||
option1 = ChoiceOption('choice', "Choice description", ("hide", "show"), default='hide', properties=('mandatory',))
|
||||
option2 = StrOption('unicode2', "Unicode 2", requires=[{'option': option1,
|
||||
'expected': 'hide',
|
||||
'action': 'hidden'}])
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option1, todict=True),
|
||||
'expected': ParamValue('hide')}))
|
||||
option2 = StrOption('unicode2', "Unicode 2", properties=(hidden_property,))
|
||||
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
||||
descr = OptionDescription("choice1_requires", "Choice with requirement", [descr1])
|
||||
return descr
|
||||
|
@ -35,7 +35,10 @@
|
||||
},
|
||||
"model": {
|
||||
"options.unicode.unicode": {
|
||||
"required": true
|
||||
"required": true,
|
||||
"properties": [
|
||||
"unique"
|
||||
]
|
||||
}
|
||||
},
|
||||
"global": {
|
||||
|
@ -1,6 +1,4 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import Leadership
|
||||
|
||||
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
def get_description():
|
||||
"""generate description for this test
|
||||
@ -8,11 +6,12 @@ def get_description():
|
||||
option = StrOption('unicode', "Unicode leader", multi=True)
|
||||
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
|
||||
option2 = StrOption('unicode2', "Values 'test' must show 'Unicode follower 3'", multi=True)
|
||||
option3 = StrOption('unicode3', "Unicode follower 3", requires=[{'option': option2,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}],
|
||||
multi=True)
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option2, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option3 = StrOption('unicode3', "Unicode follower 3", properties=(hidden_property,), multi=True)
|
||||
descr1 = Leadership("unicode", "Common configuration 1",
|
||||
[option, option1, option2, option3])
|
||||
descr = OptionDescription("options", "Common configuration 2", [descr1])
|
||||
|
@ -34,13 +34,15 @@
|
||||
},
|
||||
"model": {
|
||||
"options.unicode1": {
|
||||
"display": false,
|
||||
"properties": [
|
||||
"hidden"
|
||||
]
|
||||
},
|
||||
"options.unicode1.unicode1": {
|
||||
"required": true,
|
||||
"properties": [
|
||||
"unique"
|
||||
],
|
||||
"hidden": true,
|
||||
"display": false
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import Leadership
|
||||
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
@ -9,11 +8,13 @@ def get_description():
|
||||
option1 = StrOption('unicode1', "Unicode leader", multi=True)
|
||||
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True)
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
descr1 = Leadership("unicode1", "Common configuration",
|
||||
[option1, option2, option3], requires=[{'option': option,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}])
|
||||
[option1, option2, option3], properties=(hidden_property,))
|
||||
descr = OptionDescription("options", "Common configuration", [option, descr1])
|
||||
descr = OptionDescription("unicode1_leadership_requires_all", "Leader follower with requirement", [descr])
|
||||
return descr
|
||||
|
@ -3,46 +3,75 @@
|
||||
"options": {
|
||||
"properties": {
|
||||
"options.unicode": {
|
||||
"type": "string",
|
||||
"title": "Value 'test' must show leader"
|
||||
},
|
||||
"options.unicode1": {
|
||||
"properties": {
|
||||
"options.unicode1.unicode1": {
|
||||
"options.unicode.unicode": {
|
||||
"type": "string",
|
||||
"isMulti": true,
|
||||
"title": "Unicode leader"
|
||||
"title": "Values 'test' must show 'Unicode follower 3'"
|
||||
},
|
||||
"options.unicode1.unicode2": {
|
||||
"options.unicode.unicode1": {
|
||||
"type": "string",
|
||||
"isMulti": true,
|
||||
"title": "Unicode follower 1"
|
||||
},
|
||||
"options.unicode1.unicode3": {
|
||||
"options.unicode.unicode2": {
|
||||
"type": "string",
|
||||
"isMulti": true,
|
||||
"title": "Unicode follower 2"
|
||||
},
|
||||
"options.unicode.unicode3": {
|
||||
"type": "string",
|
||||
"isMulti": true,
|
||||
"title": "Unicode follower 3"
|
||||
}
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Common configuration"
|
||||
"title": "Common configuration 1"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"title": "Common configuration"
|
||||
"title": "Common configuration 2"
|
||||
}
|
||||
},
|
||||
"model": {
|
||||
"options.unicode1": {
|
||||
"display": false,
|
||||
"properties": [
|
||||
"hidden"
|
||||
]
|
||||
},
|
||||
"options.unicode1.unicode1": {
|
||||
"options.unicode.unicode": {
|
||||
"required": true,
|
||||
"hidden": true,
|
||||
"display": false
|
||||
"properties": [
|
||||
"unique"
|
||||
],
|
||||
"value": [
|
||||
"test",
|
||||
"val2"
|
||||
],
|
||||
"owner": "user"
|
||||
},
|
||||
"options.unicode.unicode1": {
|
||||
"0": {
|
||||
"value": "super1",
|
||||
"owner": "user"
|
||||
},
|
||||
"1": {
|
||||
"value": "super2",
|
||||
"owner": "user"
|
||||
}
|
||||
},
|
||||
"options.unicode.unicode2": {
|
||||
"0": {
|
||||
"value": "pas test",
|
||||
"owner": "user"
|
||||
},
|
||||
"1": {
|
||||
"value": "test",
|
||||
"owner": "user"
|
||||
}
|
||||
},
|
||||
"options.unicode.unicode3": {
|
||||
"1": {
|
||||
"hidden": true,
|
||||
"display": false,
|
||||
"value": "super",
|
||||
"owner": "user"
|
||||
}
|
||||
}
|
||||
},
|
||||
"global": {
|
||||
@ -62,33 +91,33 @@
|
||||
]
|
||||
},
|
||||
"form": {
|
||||
"options.unicode": {
|
||||
"options.unicode.unicode": {
|
||||
"clearable": true,
|
||||
"type": "input",
|
||||
"dependencies": {
|
||||
"default": {
|
||||
"hide": [
|
||||
"options.unicode1"
|
||||
"options.unicode.unicode3"
|
||||
]
|
||||
},
|
||||
"expected": {
|
||||
"test": {
|
||||
"show": [
|
||||
"options.unicode1"
|
||||
"options.unicode.unicode3"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"options.unicode1.unicode1": {
|
||||
"options.unicode.unicode1": {
|
||||
"clearable": true,
|
||||
"type": "input"
|
||||
},
|
||||
"options.unicode1.unicode2": {
|
||||
"options.unicode.unicode2": {
|
||||
"clearable": true,
|
||||
"type": "input"
|
||||
},
|
||||
"options.unicode1.unicode3": {
|
||||
"options.unicode.unicode3": {
|
||||
"clearable": true,
|
||||
"type": "input"
|
||||
},
|
@ -0,0 +1,33 @@
|
||||
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
"""generate description for this test
|
||||
"""
|
||||
option = StrOption('unicode', "Values 'test' must show 'Unicode follower 3'", multi=True)
|
||||
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
|
||||
option2 = StrOption('unicode2', "Unicode follower 2", multi=True)
|
||||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(option, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option3 = StrOption('unicode3', "Unicode follower 3", properties=(disabled_property,), multi=True)
|
||||
descr1 = Leadership("unicode", "Common configuration 1",
|
||||
[option, option1, option2, option3])
|
||||
descr = OptionDescription("options", "Common configuration 2", [descr1])
|
||||
descr = OptionDescription("unicode1_leadership_requires_disabled_value", "Leader followers with Unicode follower 3 disabled when Unicode follower 2 is test and modified value", [descr])
|
||||
return descr
|
||||
|
||||
|
||||
async def get_values(api, allpath=False):
|
||||
if allpath:
|
||||
root = 'unicode1_leadership_requires_disabled_value.'
|
||||
else:
|
||||
root = ''
|
||||
await api.option(root + 'options.unicode.unicode').value.set([u'test', u'val2'])
|
||||
await api.option(root + 'options.unicode.unicode1', 0).value.set(u'super1')
|
||||
await api.option(root + 'options.unicode.unicode1', 1).value.set(u'super2')
|
||||
await api.option(root + 'options.unicode.unicode2', 0).value.set(u'pas test')
|
||||
await api.option(root + 'options.unicode.unicode2', 1).value.set(u'test')
|
||||
await api.option(root + 'options.unicode.unicode3', 1).value.set(u'super')
|
@ -30,7 +30,10 @@
|
||||
},
|
||||
"model": {
|
||||
"options.unicode1.unicode1": {
|
||||
"required": true
|
||||
"required": true,
|
||||
"properties": [
|
||||
"unique"
|
||||
]
|
||||
}
|
||||
},
|
||||
"global": {
|
||||
|
@ -1,5 +1,4 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import Leadership
|
||||
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
@ -7,11 +6,12 @@ def get_description():
|
||||
"""
|
||||
option1 = StrOption('unicode1', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
||||
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True,
|
||||
requires=[{'option': option1,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}])
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option1, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True, properties=(hidden_property,))
|
||||
descr1 = Leadership("unicode1", "Common configuration",
|
||||
[option1, option2, option3])
|
||||
descr = OptionDescription("options", "Common configuration", [descr1])
|
||||
|
@ -31,6 +31,9 @@
|
||||
"model": {
|
||||
"options.unicode1.unicode1": {
|
||||
"required": true,
|
||||
"properties": [
|
||||
"unique"
|
||||
],
|
||||
"value": [
|
||||
"test",
|
||||
"pas test"
|
||||
@ -49,8 +52,8 @@
|
||||
"owner": "user"
|
||||
},
|
||||
"1": {
|
||||
"display": false,
|
||||
"hidden": true
|
||||
"hidden": true,
|
||||
"display": false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,5 +1,4 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import Leadership
|
||||
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
@ -7,15 +6,16 @@ def get_description():
|
||||
"""
|
||||
option1 = StrOption('unicode1', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
||||
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True,
|
||||
requires=[{'option': option1,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}])
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option1, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True, properties=(hidden_property,))
|
||||
descr1 = Leadership("unicode1", "Common configuration",
|
||||
[option1, option2, option3])
|
||||
descr = OptionDescription("options", "Common configuration", [descr1])
|
||||
descr = OptionDescription("unicode1_leadership_requires_follower_value", "Leader follower requires follower with leader value", [descr])
|
||||
descr = OptionDescription("unicode1_leadership_requires_follower_value", "Leader follower requires follower with leader", [descr])
|
||||
return descr
|
||||
|
||||
|
||||
|
@ -30,7 +30,10 @@
|
||||
},
|
||||
"model": {
|
||||
"options.unicode1.unicode1": {
|
||||
"required": true
|
||||
"required": true,
|
||||
"properties": [
|
||||
"unique"
|
||||
]
|
||||
}
|
||||
},
|
||||
"global": {
|
||||
|
@ -1,5 +1,4 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import Leadership
|
||||
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
@ -7,11 +6,12 @@ def get_description():
|
||||
"""
|
||||
option1 = StrOption('unicode1', "Unicode leader", multi=True)
|
||||
option2 = StrOption('unicode2', "Values 'test' must show 'Unicode follower 2'", multi=True)
|
||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True,
|
||||
requires=[{'option': option2,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}])
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option2, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True, properties=(hidden_property,))
|
||||
descr1 = Leadership("unicode1", "Common configuration",
|
||||
[option1, option2, option3])
|
||||
descr = OptionDescription("options", "Common configuration", [descr1])
|
||||
|
@ -1,19 +0,0 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import Leadership
|
||||
|
||||
|
||||
def get_description():
|
||||
"""generate description for this test
|
||||
"""
|
||||
option = StrOption('unicode', "Value 'test' must show leader")
|
||||
option1 = StrOption('unicode1', "Unicode leader", multi=True, requires=[{'option': option,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}])
|
||||
option2 = StrOption('unicode2', "Unicode follower 1", multi=True)
|
||||
option3 = StrOption('unicode3', "Unicode follower 2", multi=True)
|
||||
descr1 = Leadership("unicode1", "Common configuration",
|
||||
[option1, option2, option3])
|
||||
descr = OptionDescription("options", "Common configuration", [option, descr1])
|
||||
descr = OptionDescription("unicode1_leadership_requires_leader", "Leader follower with requirement on leader", [descr])
|
||||
return descr
|
@ -36,6 +36,9 @@
|
||||
"model": {
|
||||
"options.unicode.unicode": {
|
||||
"required": true,
|
||||
"properties": [
|
||||
"unique"
|
||||
],
|
||||
"value": [
|
||||
"test",
|
||||
"val2"
|
||||
@ -64,8 +67,8 @@
|
||||
},
|
||||
"options.unicode.unicode3": {
|
||||
"1": {
|
||||
"display": false,
|
||||
"hidden": true,
|
||||
"display": false,
|
||||
"value": "super",
|
||||
"owner": "user"
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import Leadership
|
||||
from tiramisu import StrOption, OptionDescription, Leadership, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
@ -8,11 +7,12 @@ def get_description():
|
||||
option = StrOption('unicode', "Values 'test' must show 'Unicode follower 3'", multi=True)
|
||||
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
|
||||
option2 = StrOption('unicode2', "Unicode follower 2", multi=True)
|
||||
option3 = StrOption('unicode3', "Unicode follower 3", requires=[{'option': option,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}],
|
||||
multi=True)
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option3 = StrOption('unicode3', "Unicode follower 3", properties=(hidden_property,), multi=True)
|
||||
descr1 = Leadership("unicode", "Common configuration 1",
|
||||
[option, option1, option2, option3])
|
||||
descr = OptionDescription("options", "Common configuration 2", [descr1])
|
||||
|
@ -19,8 +19,11 @@
|
||||
"model": {
|
||||
"options.unicode2": {
|
||||
"required": true,
|
||||
"display": false,
|
||||
"hidden": true
|
||||
"properties": [
|
||||
"unique"
|
||||
],
|
||||
"hidden": true,
|
||||
"display": false
|
||||
}
|
||||
},
|
||||
"global": {
|
||||
|
@ -1,15 +1,16 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
"""generate description for this test
|
||||
"""
|
||||
option1 = StrOption('unicode1', "Value 'test' must show Unicode 2")
|
||||
option2 = StrOption('unicode2', "Unicode 2", requires=[{'option': option1,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}],
|
||||
multi=True)
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option1, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option2 = StrOption('unicode2', "Unicode 2", properties=(hidden_property,), multi=True)
|
||||
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
||||
descr = OptionDescription("unicode1_multi_requires", "Unicode multi with requirement", [descr1])
|
||||
return descr
|
||||
|
@ -27,7 +27,6 @@
|
||||
},
|
||||
"model": {
|
||||
"unicode1": {
|
||||
"display": false,
|
||||
"properties": [
|
||||
"hidden"
|
||||
]
|
||||
|
@ -1,4 +1,4 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
@ -8,10 +8,11 @@ def get_description():
|
||||
descr1 = OptionDescription("options", "Common configuration", [option1])
|
||||
option2 = StrOption('unicode2', "Unicode 2")
|
||||
option3 = StrOption('unicode3', "Unicode 3")
|
||||
descr2 = OptionDescription("unicode1", "OptionDescription with 2 options",
|
||||
[option2, option3], requires=[{'option': option1,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}])
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option1, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
descr2 = OptionDescription("unicode1", "OptionDescription with 2 options", [option2, option3], properties=(hidden_property,))
|
||||
descr = OptionDescription("unicode1_optiondescription_requires", "OptionDesciption with requirement", [descr1, descr2])
|
||||
return descr
|
||||
|
@ -1,14 +1,16 @@
|
||||
from tiramisu.option import StrOption, OptionDescription
|
||||
from tiramisu import StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
|
||||
|
||||
|
||||
def get_description():
|
||||
"""generate description for this test
|
||||
"""
|
||||
option1 = StrOption('unicode1', "Value 'test' must show Unicode 2")
|
||||
option2 = StrOption('unicode2', "Unicode 2", requires=[{'option': option1,
|
||||
'expected': u'test',
|
||||
'action': 'hidden',
|
||||
'inverse': True}])
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(option1, todict=True),
|
||||
'expected': ParamValue('test'),
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option2 = StrOption('unicode2', "Unicode 2", properties=(hidden_property,))
|
||||
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
|
||||
descr = OptionDescription("unicode1_requires", "Unicode with requirement", [descr1])
|
||||
return descr
|
||||
|
@ -31,7 +31,7 @@ def list_data(ext='.py'):
|
||||
ret = []
|
||||
for filename in filenames:
|
||||
# if filename.endswith(ext) and not filename.startswith('__'):
|
||||
if filename.endswith(ext) and not filename.startswith('__') and not 'require' in filename and not 'not_equal' in filename and not 'callback' in filename and not filename == 'unicode2_copy.py' and not filename == 'unicode2_multi_copy.py':
|
||||
if filename.endswith(ext) and not filename.startswith('__') and not 'not_equal' in filename and not 'callback' in filename and not filename == 'unicode2_copy.py' and not filename == 'unicode2_multi_copy.py':
|
||||
ret.append(filename)
|
||||
return ret
|
||||
|
||||
|
@ -401,9 +401,9 @@ async def test_cache_leader_and_followers():
|
||||
values = cfg._config_bag.context._impl_values_cache
|
||||
settings = cfg._config_bag.context._impl_properties_cache
|
||||
compare(settings.get_cached(), {None: {None: (global_props, None)},
|
||||
'val1': {None: (val1_props, None)},
|
||||
'val1.val1': {None: (val1_val1_props, None)},
|
||||
'val1.val2': {idx_val2: (val1_val2_props, None)}})
|
||||
'val1': {None: (val1_props, None)},
|
||||
'val1.val1': {None: (val1_val1_props, None)},
|
||||
'val1.val2': {idx_val2: (val1_val2_props, None)}})
|
||||
# len is 0 so don't get any value
|
||||
compare(values.get_cached(), {'val1.val1': {None: ([], None)}})
|
||||
#
|
||||
|
@ -87,11 +87,7 @@ async def test_make_dict(config_type):
|
||||
d2 = await cfg.value.dict(flatten=True)
|
||||
assert d2 == {'a': True, 'int': 43}
|
||||
if config_type == 'tiramisu':
|
||||
# FIXME
|
||||
with pytest.raises(ValueError):
|
||||
d2 = await cfg.value.dict(withvalue="3")
|
||||
d = await cfg.forcepermissive.value.dict()
|
||||
assert d == {"s1.a": True, "s1.b": False, "int": 43}
|
||||
assert await cfg.forcepermissive.value.dict() == {"s1.a": True, "s1.b": False, "int": 43}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@ -113,23 +109,6 @@ async def test_make_dict_with_disabled(config_type):
|
||||
assert await cfg.unrestraint.value.dict() == {"int": 42, "s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_make_dict_with_disabled_withoption():
|
||||
descr = OptionDescription("opt", "", [
|
||||
OptionDescription("s1", "", [
|
||||
BoolOption("a", "", default=False),
|
||||
BoolOption("b", "", default=False, properties=('disabled',))]),
|
||||
OptionDescription("s2", "", [
|
||||
BoolOption("a", "", default=False),
|
||||
BoolOption("b", "", default=False)], properties=('disabled',)),
|
||||
IntOption("int", "", default=42)])
|
||||
cfg = await Config(descr)
|
||||
await cfg.property.read_only()
|
||||
assert await cfg.value.dict(withoption="a") == {"s1.a": False}
|
||||
assert await cfg.forcepermissive.value.dict(withoption="a") == {"s1.a": False}
|
||||
assert await cfg.unrestraint.value.dict(withoption="a") == {"s1.a": False, "s1.b": False, "s2.a": False, "s2.b": False}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_make_dict_with_disabled_in_callback(config_type):
|
||||
descr = OptionDescription("opt", "", [
|
||||
|
@ -9,7 +9,7 @@ from tiramisu import BoolOption, StrOption, ChoiceOption, IPOption, \
|
||||
StrOption, PortOption, BroadcastOption, DomainnameOption, \
|
||||
EmailOption, URLOption, UsernameOption, FilenameOption, SymLinkOption, \
|
||||
OptionDescription, DynOptionDescription, SynDynOption, submulti, Leadership, \
|
||||
Config, Params, ParamOption, ParamValue, ParamSuffix, ParamSelfOption, Calculation, calc_value
|
||||
Config, Params, ParamOption, ParamValue, ParamSuffix, ParamSelfOption, ParamIndex, Calculation, calc_value
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError, ConflictError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
@ -761,9 +761,6 @@ async def test_makedict_dyndescription_context():
|
||||
await cfg.option('od.dodval1.stval1').value.set('yes')
|
||||
assert await cfg.value.dict() == {'od.val1': ['val1', 'val2'], 'od.dodval1.stval1': 'yes', 'od.dodval2.stval2': None}
|
||||
assert await cfg.value.dict(flatten=True) == {'val1': ['val1', 'val2'], 'stval1': 'yes', 'stval2': None}
|
||||
assert await cfg.value.dict(withoption='stval1') == {'od.dodval1.stval1': 'yes'}
|
||||
assert await cfg.option('od').value.dict(withoption='stval1') == {'dodval1.stval1': 'yes'}
|
||||
assert await cfg.option('od.dodval1').value.dict(withoption='stval1') == {'stval1': 'yes'}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@ -1549,3 +1546,89 @@ async def test_leadership_callback_samegroup_dyndescription_convert():
|
||||
assert await cfg.option('od.stval1.st1val1.st2val1', 0).owner.get() == owner
|
||||
assert await cfg.option('od.stval1.st1val1.st3val1', 0).owner.isdefault()
|
||||
assert await cfg.option('od.stval2.st1val2.st1val2').owner.isdefault()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dyn_with_leader_hidden_in_config():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, properties=('hidden',))
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0], properties=('hidden',))
|
||||
dyn = DynOptionDescription('leader', '', [interface1], suffixes=Calculation(return_list))
|
||||
od = OptionDescription('root', '', [dyn])
|
||||
cfg = await Config(od)
|
||||
await cfg.property.read_write()
|
||||
await cfg.permissive.add('hidden')
|
||||
assert await cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == []
|
||||
await cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.1'])
|
||||
assert await cfg.forcepermissive.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get()
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get()
|
||||
await cfg.value.dict(leader_to_list=True) == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.1'}],
|
||||
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': [{'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': '192.168.1.1'}]}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_dyn_leadership_requires():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(ip_admin_eth0, notraisepropertyerror=True),
|
||||
'expected': ParamValue('192.168.1.1'),
|
||||
'no_condition_is_invalid': ParamValue(True),
|
||||
'index': ParamIndex()}))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, properties=(disabled_property,))
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
dyn = DynOptionDescription('leader', '', [interface1], suffixes=Calculation(return_list))
|
||||
od = OptionDescription('toto', '', [dyn])
|
||||
cfg = await Config(od)
|
||||
await cfg.property.read_write()
|
||||
assert await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == []
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2'])
|
||||
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||
assert await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.get() == ['192.168.1.2']
|
||||
#
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.1'])
|
||||
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get()
|
||||
#
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.2'])
|
||||
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get() is None
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.set('255.255.255.255')
|
||||
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get() == '255.255.255.255'
|
||||
assert await cfg.value.dict() == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': ['192.168.1.2', '192.168.1.2'],
|
||||
'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': [None, '255.255.255.255'],
|
||||
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': [],
|
||||
'leaderval2.ip_admin_eth0val2.netmask_admin_eth0val2': []}
|
||||
|
||||
ret = await cfg.value.dict(leader_to_list=True)
|
||||
assert ret == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': None},
|
||||
{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': '255.255.255.255'}],
|
||||
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': []}
|
||||
|
||||
#
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.ip_admin_eth0val1').value.set(['192.168.1.2', '192.168.1.1'])
|
||||
assert await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 0).value.get() is None
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
await cfg.option('leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 1).value.get()
|
||||
ret = await cfg.value.dict()
|
||||
assert set(ret.keys()) == set(['leaderval1.ip_admin_eth0val1.ip_admin_eth0val1', 'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1', 'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2', 'leaderval2.ip_admin_eth0val2.netmask_admin_eth0val2'])
|
||||
assert ret['leaderval1.ip_admin_eth0val1.ip_admin_eth0val1'] == ['192.168.1.2', '192.168.1.1']
|
||||
assert len(ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1']) == 2
|
||||
assert ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1'][0] is None
|
||||
assert isinstance(ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1'][1], PropertiesOptionError)
|
||||
del ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1'][1]
|
||||
del ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1'][0]
|
||||
del ret['leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1']
|
||||
assert await cfg.value.dict(leader_to_list=True) == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2',
|
||||
'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': None},
|
||||
{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.1'}],
|
||||
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': []}
|
||||
#
|
||||
assert await cfg.value.dict(leader_to_list=True) == {'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': [{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.2',
|
||||
'leaderval1.ip_admin_eth0val1.netmask_admin_eth0val1': None},
|
||||
{'leaderval1.ip_admin_eth0val1.ip_admin_eth0val1': '192.168.1.1'}],
|
||||
'leaderval2.ip_admin_eth0val2.ip_admin_eth0val2': []}
|
||||
|
@ -91,25 +91,6 @@ async def test_base_config(config_type):
|
||||
await cfg.send()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_make_dict_filter():
|
||||
descr = make_description()
|
||||
cfg = await Config(descr)
|
||||
await cfg.property.read_write()
|
||||
subresult = {'numero_etab': None, 'nombre_interfaces': 1,
|
||||
'serveur_ntp': [], 'mode_conteneur_actif': False,
|
||||
'time_zone': 'Paris', 'nom_machine': 'eoleng',
|
||||
'activer_proxy_client': False}
|
||||
result = {}
|
||||
for key, value in subresult.items():
|
||||
result['general.' + key] = value
|
||||
assert await cfg.option('creole').value.dict(withoption='numero_etab') == result
|
||||
with pytest.raises(AttributeError):
|
||||
await cfg.option('creole').value.dict(withoption='numero_etab', withvalue='toto')
|
||||
assert await cfg.option('creole').value.dict(withoption='numero_etab', withvalue=None) == result
|
||||
assert await cfg.option('creole.general').value.dict(withoption='numero_etab') == subresult
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_group_type():
|
||||
descr = make_description()
|
||||
@ -289,6 +270,7 @@ async def test_groups_with_leader_make_dict(config_type):
|
||||
cfg = await Config(od)
|
||||
cfg = await get_config(cfg, config_type)
|
||||
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': []}
|
||||
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': []}
|
||||
if config_type != 'tiramisu-api':
|
||||
# FIXME useful? already in leadership
|
||||
assert await cfg.option('ip_admin_eth0.ip_admin_eth0').value.len() == 0
|
||||
@ -299,6 +281,7 @@ async def test_groups_with_leader_make_dict(config_type):
|
||||
assert await cfg.option('ip_admin_eth0.ip_admin_eth0').value.len() == 2
|
||||
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0').value.len() == 2
|
||||
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['ip1', 'ip2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None]}
|
||||
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': 'ip1', 'ip_admin_eth0.netmask_admin_eth0': None}, {'ip_admin_eth0.ip_admin_eth0': 'ip2', 'ip_admin_eth0.netmask_admin_eth0': None}]}
|
||||
if config_type == 'tiramisu-api':
|
||||
await cfg.send()
|
||||
|
||||
@ -365,6 +348,7 @@ async def test_groups_with_leader_hidden_in_config():
|
||||
await cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get()
|
||||
await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}]}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
@ -1085,7 +1085,9 @@ async def test_leadership_requires(config_type):
|
||||
await cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('255.255.255.255')
|
||||
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.get() == '255.255.255.255'
|
||||
assert await cfg.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['192.168.1.2', '192.168.1.2'],
|
||||
'ip_admin_eth0.netmask_admin_eth0': [None, '255.255.255.255']}
|
||||
'ip_admin_eth0.netmask_admin_eth0': [None, '255.255.255.255']}
|
||||
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': '192.168.1.2', 'ip_admin_eth0.netmask_admin_eth0': None},
|
||||
{'ip_admin_eth0.ip_admin_eth0': '192.168.1.2', 'ip_admin_eth0.netmask_admin_eth0': '255.255.255.255'}]}
|
||||
#
|
||||
await cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1'])
|
||||
assert await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None
|
||||
@ -1100,6 +1102,9 @@ async def test_leadership_requires(config_type):
|
||||
del ret['ip_admin_eth0.netmask_admin_eth0'][1]
|
||||
del ret['ip_admin_eth0.netmask_admin_eth0'][0]
|
||||
del ret['ip_admin_eth0.netmask_admin_eth0']
|
||||
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': '192.168.1.2',
|
||||
'ip_admin_eth0.netmask_admin_eth0': None},
|
||||
{'ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}]}
|
||||
#
|
||||
await cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.255')
|
||||
ret = await cfg.value.dict()
|
||||
@ -1111,6 +1116,9 @@ async def test_leadership_requires(config_type):
|
||||
del ret['ip_admin_eth0.netmask_admin_eth0'][1]
|
||||
del ret['ip_admin_eth0.netmask_admin_eth0'][0]
|
||||
del ret['ip_admin_eth0.netmask_admin_eth0']
|
||||
assert await cfg.value.dict(leader_to_list=True) == {'ip_admin_eth0.ip_admin_eth0': [{'ip_admin_eth0.ip_admin_eth0': '192.168.1.2',
|
||||
'ip_admin_eth0.netmask_admin_eth0': '255.255.255.255'},
|
||||
{'ip_admin_eth0.ip_admin_eth0': '192.168.1.1'}]}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
@ -144,7 +144,6 @@ async def test_slots_config():
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(od2,
|
||||
'a',
|
||||
None,
|
||||
ConfigBag(c._config_bag.context, None, None))
|
||||
sc = await c._config_bag.context.get_subconfig(option_bag)
|
||||
assert isinstance(sc, SubConfig)
|
||||
|
Reference in New Issue
Block a user