not Params object for callback, validator and calculated values for choiceoption
This commit is contained in:
@ -8,7 +8,7 @@ from .autopath import do_autopath
|
||||
do_autopath()
|
||||
from tiramisu import Config, MetaConfig, \
|
||||
StrOption, SymLinkOption, OptionDescription, MasterSlaves, DynOptionDescription, \
|
||||
getapi, submulti, undefined, owners
|
||||
getapi, submulti, undefined, owners, Params, ParamOption
|
||||
from tiramisu.error import PropertiesOptionError, APIError, ConfigError, SlaveError
|
||||
from tiramisu.api import display_count
|
||||
from collections import OrderedDict
|
||||
@ -1503,7 +1503,7 @@ def make_conf(options, meta, multi, default, default_multi, require, consistency
|
||||
if callback:
|
||||
largs = [path + 'call', "{}'s callback option".format(path)]
|
||||
objcall = tiramisu_option(*largs, **call_kwargs)
|
||||
kwargs['callback_params'] = {'': ((objcall, False),)}
|
||||
kwargs['callback_params'] = Params(ParamOption(objcall))
|
||||
else:
|
||||
objcall = None
|
||||
if symlink and not path.endswith('extraoptconsistency'):
|
||||
|
@ -9,7 +9,7 @@ from tiramisu.option import BoolOption, IPOption, IntOption, StrOption, OptionDe
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.error import ConfigError, PropertiesOptionError
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu import getapi, undefined
|
||||
from tiramisu import getapi, undefined, Params, ParamValue, ParamOption
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
|
||||
|
||||
@ -431,10 +431,10 @@ def return_value(value=None):
|
||||
|
||||
def test_cache_callback():
|
||||
val1 = StrOption('val1', "", 'val')
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params={'': ('yes',)})
|
||||
val4 = StrOption('val4', "", callback=return_value, callback_params={'value': ((val1, False),)})
|
||||
val5 = StrOption('val5', "", callback=return_value, callback_params={'value': ('yes',)}, multi=True)
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params=Params((ParamOption(val1),)), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params=Params((ParamValue('yes'),)))
|
||||
val4 = StrOption('val4', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}), multi=True)
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
||||
cfg = Config(maconfig)
|
||||
api = getapi(cfg)
|
||||
@ -602,7 +602,7 @@ def test_cache_master_and_slaves_master():
|
||||
|
||||
def test_cache_master_callback():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'value': ((val1, False),)})
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
@ -790,7 +790,7 @@ def test_cache_global_properties():
|
||||
|
||||
def test_callback_value_incr():
|
||||
val1 = IntOption('val1', "", callback=return_incr, properties=('expire',))
|
||||
val2 = IntOption('val2', "", callback=return_value, callback_params={'value': ((val1, False),)})
|
||||
val2 = IntOption('val2', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2])
|
||||
cfg = Config(maconfig)
|
||||
api = getapi(cfg)
|
||||
|
@ -8,7 +8,7 @@ from tiramisu.setting import owners
|
||||
from tiramisu.option import ChoiceOption, StrOption, OptionDescription
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.error import ConfigError
|
||||
from tiramisu import getapi, undefined
|
||||
from tiramisu import getapi, undefined, Params, ParamValue, ParamOption
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ def test_choiceoption_function_error():
|
||||
|
||||
|
||||
def test_choiceoption_function_error_args():
|
||||
choice = ChoiceOption('choice', '', values=return_error, values_params={'': ('val1',)})
|
||||
choice = ChoiceOption('choice', '', values=return_error, values_params=Params((ParamValue('val1'),)))
|
||||
odesc = OptionDescription('od', '', [choice])
|
||||
cfg = Config(odesc)
|
||||
api = getapi(cfg)
|
||||
@ -93,7 +93,7 @@ def test_choiceoption_function_error_args():
|
||||
|
||||
|
||||
def test_choiceoption_function_error_kwargs():
|
||||
choice = ChoiceOption('choice', '', values=return_error, values_params={'kwargs': ('val1',)})
|
||||
choice = ChoiceOption('choice', '', values=return_error, values_params=Params(kwargs={'kwargs': ParamValue('val1')}))
|
||||
odesc = OptionDescription('od', '', [choice])
|
||||
cfg = Config(odesc)
|
||||
api = getapi(cfg)
|
||||
@ -102,7 +102,7 @@ def test_choiceoption_function_error_kwargs():
|
||||
|
||||
|
||||
def test_choiceoption_calc_function():
|
||||
choice = ChoiceOption('choice', "", values=return_calc_list, values_params={'': ('val1',)})
|
||||
choice = ChoiceOption('choice', "", values=return_calc_list, values_params=Params((ParamValue('val1'),)))
|
||||
odesc = OptionDescription('od', '', [choice])
|
||||
cfg = Config(odesc)
|
||||
api = getapi(cfg)
|
||||
@ -125,7 +125,7 @@ def test_choiceoption_calc_opt_function():
|
||||
choice = ChoiceOption('choice',
|
||||
"",
|
||||
values=return_calc_list,
|
||||
values_params={'': ((str_, False),)})
|
||||
values_params=Params((ParamOption(str_),)))
|
||||
odesc = OptionDescription('od', '', [str_, choice])
|
||||
cfg = Config(odesc)
|
||||
api = getapi(cfg)
|
||||
@ -148,7 +148,7 @@ def test_choiceoption_calc_opt_function_propertyerror():
|
||||
choice = ChoiceOption('choice',
|
||||
"",
|
||||
values=return_calc_list,
|
||||
values_params={'': ((str_, False),)})
|
||||
values_params=Params((ParamOption(str_),)))
|
||||
odesc = OptionDescription('od', '', [str_, choice])
|
||||
cfg = Config(odesc)
|
||||
api = getapi(cfg)
|
||||
@ -165,13 +165,13 @@ def test_choiceoption_calc_opt_multi_function():
|
||||
"",
|
||||
default_multi='val2',
|
||||
values=return_val,
|
||||
values_params={'': ((str_, False),)},
|
||||
values_params=Params((ParamOption(str_),)),
|
||||
multi=True)
|
||||
ch2 = ChoiceOption('ch2',
|
||||
"",
|
||||
default=['val2'],
|
||||
values=return_val,
|
||||
values_params={'': ((str_, False),)},
|
||||
values_params=Params((ParamOption(str_),)),
|
||||
multi=True)
|
||||
odesc = OptionDescription('od', '', [str_, choice, ch2])
|
||||
cfg = Config(odesc)
|
||||
@ -203,7 +203,7 @@ def test_choiceoption_calc_invalid():
|
||||
str_
|
||||
raises(ValueError,
|
||||
"choice = ChoiceOption('choice', '', default_multi='val2', values=[1, 2, 3], \
|
||||
values_params={'': ((str_, False),)}, multi=True)")
|
||||
values_params=Params((ParamOption(str_),)), multi=True)")
|
||||
|
||||
|
||||
def test_choiceoption_calc_not_list():
|
||||
@ -212,7 +212,7 @@ def test_choiceoption_calc_not_list():
|
||||
"",
|
||||
default_multi='val2',
|
||||
values=return_val,
|
||||
values_params={'': ((str_, False),)},
|
||||
values_params=Params((ParamOption(str_),)),
|
||||
multi=True)
|
||||
odesc = OptionDescription('od', '', [str_, choice])
|
||||
cfg = Config(odesc)
|
||||
|
@ -4,7 +4,7 @@ do_autopath()
|
||||
|
||||
from tiramisu import BoolOption, IntOption, StrOption, IPOption, NetmaskOption, \
|
||||
SymLinkOption, OptionDescription, DynOptionDescription, submulti, \
|
||||
Config, GroupConfig, MetaConfig, getapi
|
||||
Config, GroupConfig, MetaConfig, getapi, Params, ParamOption
|
||||
import weakref
|
||||
|
||||
|
||||
@ -204,7 +204,7 @@ def test_deref_validator():
|
||||
if not IS_DEREFABLE:
|
||||
return
|
||||
a = StrOption('a', '', default='yes')
|
||||
b = StrOption('b', '', validator=funcname, validator_params={'': ((a, False),)}, default='val')
|
||||
b = StrOption('b', '', validator=funcname, validator_params=Params((ParamOption(a),)), default='val')
|
||||
od = OptionDescription('root', '', [a, b])
|
||||
cfg = Config(od)
|
||||
w = weakref.ref(a)
|
||||
@ -237,7 +237,7 @@ def test_deref_callback():
|
||||
if not IS_DEREFABLE:
|
||||
return
|
||||
a = StrOption('a', "", 'val')
|
||||
b = StrOption('b', "", callback=funcname, callback_params={'': ((a, False),)})
|
||||
b = StrOption('b', "", callback=funcname, callback_params=Params((ParamOption(a),)))
|
||||
od = OptionDescription('root', '', [a, b])
|
||||
cfg = Config(od)
|
||||
w = weakref.ref(a)
|
||||
@ -304,7 +304,7 @@ def test_deref_dyn():
|
||||
return
|
||||
a = StrOption('a', '', ['val1', 'val2'], multi=True)
|
||||
b = StrOption('b', '')
|
||||
dod = DynOptionDescription('dod', '', [b], callback=funcname, callback_params={'': ((a, False),)})
|
||||
dod = DynOptionDescription('dod', '', [b], callback=funcname, callback_params=Params((ParamOption(a),)))
|
||||
od = OptionDescription('od', '', [dod, a])
|
||||
cfg = Config(od)
|
||||
w = weakref.ref(a)
|
||||
|
@ -8,7 +8,7 @@ from tiramisu import BoolOption, StrOption, ChoiceOption, IPOption, \
|
||||
UnicodeOption, PortOption, BroadcastOption, DomainnameOption, \
|
||||
EmailOption, URLOption, UsernameOption, FilenameOption, SymLinkOption, \
|
||||
OptionDescription, DynOptionDescription, DynSymLinkOption, submulti, MasterSlaves, \
|
||||
Config, getapi
|
||||
Config, getapi, Params, ParamOption, ParamValue
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError, ConflictError
|
||||
from tiramisu.storage import delete_session
|
||||
|
||||
@ -290,7 +290,7 @@ def test_mandatory_dyndescription():
|
||||
def test_build_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st1 = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st1], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st1], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od1 = OptionDescription('od', '', [dod, val1])
|
||||
cfg = Config(od1)
|
||||
api = getapi(cfg)
|
||||
@ -300,7 +300,7 @@ def test_build_dyndescription_context():
|
||||
def test_subpath_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st1 = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st1], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st1], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od1 = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od1])
|
||||
api = getapi(Config(od2))
|
||||
@ -310,7 +310,7 @@ def test_subpath_dyndescription_context():
|
||||
def test_list_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = getapi(Config(od2))
|
||||
@ -322,7 +322,7 @@ def test_list_dyndescription_context():
|
||||
def test_mod_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = getapi(Config(od2))
|
||||
@ -346,7 +346,7 @@ def test_mod_dyndescription_context():
|
||||
def test_del_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = getapi(Config(od2))
|
||||
@ -362,7 +362,7 @@ def test_del_dyndescription_context():
|
||||
def test_multi_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '', multi=True)
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = getapi(Config(od2))
|
||||
@ -390,7 +390,7 @@ def test_multi_dyndescription_context():
|
||||
def test_prop_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '', properties=('test',))
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = getapi(Config(od2))
|
||||
@ -431,7 +431,7 @@ def test_callback_dyndescription_context():
|
||||
def test_mandatory_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '', properties=('mandatory',))
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = getapi(Config(od2))
|
||||
@ -453,7 +453,7 @@ def test_mandatory_dyndescription_context():
|
||||
def test_increase_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '', properties=('mandatory',))
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = getapi(Config(od2))
|
||||
@ -470,7 +470,7 @@ def test_increase_dyndescription_context():
|
||||
def test_decrease_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '', properties=('mandatory',))
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params={'': ((val1, False),)})
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
api = getapi(Config(od2))
|
||||
@ -594,7 +594,7 @@ def test_requires_dyndescription2():
|
||||
|
||||
def test_validator_dyndescription():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '', validator=return_true, validator_params={'': ('yes',)}, default='val')
|
||||
st = StrOption('st', '', validator=return_true, validator_params=Params((ParamValue('yes'),)), default='val')
|
||||
dod = DynOptionDescription('dod', '', [st], callback=return_list)
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
@ -1027,7 +1027,7 @@ def test_masterslaves_submulti_dyndescription():
|
||||
|
||||
def test_masterslaves_callback_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'value': ((st1, False),)})
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params=Params(kwargs={'value': ParamOption(st1)}))
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
st1 = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od1 = OptionDescription('od', '', [st1])
|
||||
@ -1088,7 +1088,7 @@ def test_masterslaves_callback_dyndescription():
|
||||
|
||||
def test_masterslaves_callback_value_dyndescription():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'value': ('val',)})
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params=Params(kwargs={'value': ParamValue('val')}))
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
st = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od = OptionDescription('od', '', [st])
|
||||
@ -1104,7 +1104,7 @@ def test_masterslaves_callback_value_dyndescription():
|
||||
def test_masterslaves_callback_nomulti_dyndescription():
|
||||
v11 = StrOption('v1', '', "val")
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params={'': ((v11, False),)})
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_dynval, callback_params=Params(ParamOption(v11)))
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
stt = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od1 = OptionDescription('od', '', [stt])
|
||||
@ -1119,7 +1119,7 @@ def test_masterslaves_callback_nomulti_dyndescription():
|
||||
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),)})
|
||||
st3 = StrOption('st3', "", multi=True, callback=return_dynval, callback_params=Params(ParamOption(st2)))
|
||||
stm = MasterSlaves('st1', '', [st1, st2, st3])
|
||||
stt = DynOptionDescription('st', '', [stm], callback=return_list)
|
||||
od1 = OptionDescription('od', '', [stt])
|
||||
|
@ -8,7 +8,7 @@ from py.test import raises
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption, MasterSlaves, Config, \
|
||||
getapi
|
||||
getapi, Params, ParamContext, ParamOption, ParamValue
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
|
||||
|
||||
@ -194,14 +194,14 @@ def test_force_store_value_callback():
|
||||
|
||||
|
||||
def test_force_store_value_callback_params():
|
||||
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val2, callback_params={'value': (2,)})
|
||||
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val2, callback_params=Params(kwargs={'value': ParamValue(2)}))
|
||||
descr = OptionDescription("int", "", [b])
|
||||
api = getapi(Config(descr))
|
||||
assert api.value.exportation() == (('int',), (None,), (2,), ('forced',))
|
||||
|
||||
|
||||
def test_force_store_value_callback_params_2():
|
||||
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val3, callback_params={'': ((None,),), 'value': (2,)})
|
||||
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val3, callback_params=Params(ParamContext(), {'value': ParamValue(2)}))
|
||||
descr = OptionDescription("int", "", [b])
|
||||
api = getapi(Config(descr))
|
||||
assert api.value.exportation() == (('int',), (None,), (2,), ('forced',))
|
||||
@ -209,7 +209,7 @@ def test_force_store_value_callback_params_2():
|
||||
|
||||
def test_force_store_value_callback_params_with_opt():
|
||||
a = IntOption('val1', "", 2)
|
||||
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val2, callback_params={'value': ((a, False),)})
|
||||
b = IntOption('int', 'Test int option', properties=('force_store_value',), callback=return_val2, callback_params=Params(kwargs={'value': ParamOption(a)}))
|
||||
descr = OptionDescription("int", "", [a, b])
|
||||
api = getapi(Config(descr))
|
||||
assert api.value.exportation() == (('int',), (None,), (2,), ('forced',))
|
||||
|
@ -6,7 +6,7 @@ from py.test import raises
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
from tiramisu.config import Config
|
||||
from tiramisu import IntOption, StrOption, UnicodeOption, OptionDescription, \
|
||||
SymLinkOption, MasterSlaves, getapi, undefined
|
||||
SymLinkOption, MasterSlaves, getapi, undefined, Params, ParamOption
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
from tiramisu.setting import groups
|
||||
|
||||
@ -38,7 +38,7 @@ def make_description2():
|
||||
stroption2 = SymLinkOption('unicode2', stroption1)
|
||||
stroption3 = StrOption('str3', 'Test string option', multi=True,
|
||||
properties=('mandatory', ))
|
||||
unicode1 = UnicodeOption('unicode1', 'Test string option', callback=return_value, callback_params={'': ((stroption, False),)}, properties=('mandatory', ))
|
||||
unicode1 = UnicodeOption('unicode1', 'Test string option', callback=return_value, callback_params=Params(ParamOption(stroption)), properties=('mandatory', ))
|
||||
descr = OptionDescription('tiram', '', [stroption, stroption1, stroption2, stroption3, unicode1])
|
||||
return descr
|
||||
|
||||
@ -63,8 +63,8 @@ def make_description3():
|
||||
stroption2 = SymLinkOption('unicode2', stroption1)
|
||||
stroption3 = StrOption('str3', 'Test string option', multi=True,
|
||||
properties=('mandatory', ))
|
||||
unicode1 = UnicodeOption('unicode1', 'Test string option', callback=return_value, callback_params={'': ((stroption, False),)}, properties=('mandatory', ))
|
||||
int1 = IntOption('int1', '', callback=return_value, callback_params={'': ((stroption, False),)}, properties=('mandatory', ))
|
||||
unicode1 = UnicodeOption('unicode1', 'Test string option', callback=return_value, callback_params=Params(ParamOption(stroption)), properties=('mandatory', ))
|
||||
int1 = IntOption('int1', '', callback=return_value, callback_params=Params(ParamOption(stroption)), properties=('mandatory', ))
|
||||
descr = OptionDescription('tiram', '', [stroption, stroption1, stroption2, stroption3, unicode1, int1])
|
||||
return descr
|
||||
|
||||
|
@ -6,7 +6,7 @@ from py.test import raises
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import IntOption, StrOption, NetworkOption, NetmaskOption, \
|
||||
OptionDescription, MasterSlaves, Config, GroupConfig, MetaConfig, \
|
||||
getapi
|
||||
getapi, Params, ParamOption, ParamValue
|
||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, SlaveError
|
||||
|
||||
owners.addowner('meta1')
|
||||
@ -587,33 +587,33 @@ def test_meta_exception_meta():
|
||||
|
||||
def test_meta_callback():
|
||||
val1 = StrOption('val1', "", 'val')
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params={'': ('yes',)})
|
||||
val4 = StrOption('val4', "", callback=return_value, callback_params={'value': ((val1, False),)})
|
||||
val5 = StrOption('val5', "", callback=return_value, callback_params={'value': ('yes',)})
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params=Params(ParamValue('yes')))
|
||||
val4 = StrOption('val4', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
||||
cfg = Config(maconfig, session_id='cfg')
|
||||
api = getapi(MetaConfig([cfg]))
|
||||
api.property.read_write()
|
||||
assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
||||
api.config('cfg').option('val1').value.set('new')
|
||||
assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||
api.config('cfg').option('val1').value.reset()
|
||||
api.option('val1').value.set('new')
|
||||
assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||
api.config('cfg').option('val4').value.set('new1')
|
||||
assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||
api.config('cfg').option('val4').value.reset()
|
||||
api.option('val4').value.set('new1')
|
||||
assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||
api.option('val4').value.reset()
|
||||
#assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||
#api.config('cfg').option('val1').value.reset()
|
||||
#api.option('val1').value.set('new')
|
||||
#assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
||||
#api.config('cfg').option('val4').value.set('new1')
|
||||
#assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||
#api.config('cfg').option('val4').value.reset()
|
||||
#api.option('val4').value.set('new1')
|
||||
#assert api.config('cfg').option.make_dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
||||
#api.option('val4').value.reset()
|
||||
|
||||
|
||||
def test_meta_callback_slave():
|
||||
val = StrOption('val', "", default='val')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val, False),)})
|
||||
val3 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val4 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val)))
|
||||
val3 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
val4 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
|
@ -7,7 +7,7 @@ from tiramisu.config import Config
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import ChoiceOption, BoolOption, IntOption, FloatOption, \
|
||||
StrOption, OptionDescription, SymLinkOption, IPOption, NetmaskOption, MasterSlaves, \
|
||||
getapi, undefined
|
||||
getapi, undefined, Params, ParamOption, ParamValue, ParamContext
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
from tiramisu.error import PropertiesOptionError, ConflictError, SlaveError, ConfigError
|
||||
from tiramisu.i18n import _
|
||||
@ -237,7 +237,7 @@ def test_callback():
|
||||
|
||||
|
||||
def test_callback_params_without_callback():
|
||||
raises(ValueError, "StrOption('val2', '', callback_params={'': ('yes',)})")
|
||||
raises(ValueError, "StrOption('val2', '', callback_params=Params(ParamValue('yes')))")
|
||||
|
||||
|
||||
def test_callback_invalid():
|
||||
@ -253,29 +253,37 @@ def test_callback_invalid():
|
||||
|
||||
|
||||
def test_callback_with_context():
|
||||
val1 = StrOption("val1", "", callback=is_config, callback_params={'': ((None,),), 'value': ('string',)})
|
||||
#val1 = StrOption("val1", "", callback=is_config, callback_params={'': ((None,),), 'value': ('string',)})
|
||||
context = ParamContext()
|
||||
value = ParamValue('string')
|
||||
params = Params((context,), {'value': value})
|
||||
val1 = StrOption("val1", "", callback=is_config, callback_params=params)
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
api = getapi(Config(maconfig))
|
||||
assert api.option('val1').value.get() == 'yes'
|
||||
|
||||
|
||||
def test_callback_with_context_named():
|
||||
val1 = StrOption("val1", "", callback=is_config, callback_params={'config': ((None,),)})
|
||||
context = ParamContext()
|
||||
params = Params(kwargs={'config': context})
|
||||
val1 = StrOption("val1", "", callback=is_config, callback_params=params)
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
api = getapi(Config(maconfig))
|
||||
assert api.option('val1').value.get() == 'yes'
|
||||
|
||||
|
||||
def test_callback_with_error():
|
||||
val1 = StrOption("val1", "", callback=is_config, callback_params={'': ('string',), 'value': ('string',)})
|
||||
val1 = StrOption("val1", "", callback=is_config, callback_params=Params(ParamValue('string'), kwargs={'value': ParamValue('string')}))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
api = getapi(Config(maconfig))
|
||||
assert api.option('val1').value.get() == 'no'
|
||||
|
||||
|
||||
def test_callback_with_context_value():
|
||||
context = ParamContext()
|
||||
params = Params((context,))
|
||||
val1 = StrOption("val1", "")
|
||||
val2 = StrOption("val2", "", callback=ret_from_config, callback_params={'': ((None,),)})
|
||||
val2 = StrOption("val2", "", callback=ret_from_config, callback_params=params)
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2])
|
||||
api = getapi(Config(maconfig))
|
||||
api.option('val1').value.set('yes')
|
||||
@ -288,10 +296,10 @@ def test_callback_with_context_value():
|
||||
|
||||
def test_callback_value():
|
||||
val1 = StrOption('val1', "", 'val')
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params={'': ('yes',)})
|
||||
val4 = StrOption('val4', "", callback=return_value, callback_params={'value': ((val1, False),)})
|
||||
val5 = StrOption('val5', "", callback=return_value, callback_params={'value': ('yes',)})
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params=Params(ParamValue('yes')))
|
||||
val4 = StrOption('val4', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(ParamValue('yes')))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
||||
api = getapi(Config(maconfig))
|
||||
api.property.read_write()
|
||||
@ -313,9 +321,8 @@ def test_callback_value():
|
||||
def test_callback_value_tuple():
|
||||
val1 = StrOption('val1', "", 'val1')
|
||||
val2 = StrOption('val2', "", 'val2')
|
||||
val3 = StrOption('val3', "", callback=return_concat, callback_params={'': ((val1, False), (val2, False))})
|
||||
val4 = StrOption('val4', "", callback=return_concat, callback_params={'': ('yes', 'no')})
|
||||
raises(ValueError, "StrOption('val4', '', callback=return_concat, callback_params={'value': ('yes', 'no')})")
|
||||
val3 = StrOption('val3', "", callback=return_concat, callback_params=Params((ParamOption(val1), ParamOption(val2))))
|
||||
val4 = StrOption('val4', "", callback=return_concat, callback_params=Params((ParamValue('yes'), ParamValue('no'))))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4])
|
||||
api = getapi(Config(maconfig))
|
||||
api.property.read_write()
|
||||
@ -331,8 +338,8 @@ def test_callback_value_tuple():
|
||||
|
||||
def test_callback_value_force_permissive():
|
||||
val1 = StrOption('val1', "", 'val', properties=('disabled',))
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params={'': ((val1, True),)})
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params=Params(ParamOption(val1, True)))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3])
|
||||
api = getapi(Config(maconfig))
|
||||
api.property.read_only()
|
||||
@ -343,7 +350,7 @@ def test_callback_value_force_permissive():
|
||||
def test_callback_symlink():
|
||||
val1 = StrOption('val1', "", 'val')
|
||||
val2 = SymLinkOption('val2', val1)
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params={'': ((val2, False),)})
|
||||
val3 = StrOption('val3', "", callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3])
|
||||
api = getapi(Config(maconfig))
|
||||
api.property.read_write()
|
||||
@ -368,7 +375,8 @@ def test_callback_list():
|
||||
|
||||
def test_callback_list2():
|
||||
val1 = StrOption('val1', "", callback=return_list)
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params={'': ((val1, False),)})
|
||||
#val2 = StrOption('val2', "", callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
val2 = StrOption('val2', "", callback=return_value, callback_params=Params(ParamOption(val1))) # , 'forcepermissive': False}]})
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2])
|
||||
api = getapi(Config(maconfig))
|
||||
api.property.read_write()
|
||||
@ -393,9 +401,17 @@ def test_callback_multi():
|
||||
|
||||
def test_callback_multi_value():
|
||||
val1 = StrOption('val1', "", ['val'], multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ('yes',)})
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_list2, callback_params={'': ((val1, False), 'yes')})
|
||||
#val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
#val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamValue('yes')))
|
||||
#val4 = StrOption('val4', "", multi=True, callback=return_list2, callback_params={'': ((val1, False), 'yes')})
|
||||
option = ParamOption(val1)
|
||||
params1 = Params((option,))
|
||||
value = ParamValue('yes')
|
||||
params2 = Params((value,))
|
||||
params3 = Params((option, value))
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params=params1)
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=params2)
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_list2, callback_params=params3)
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4])
|
||||
api = getapi(Config(maconfig))
|
||||
api.property.read_write()
|
||||
@ -435,7 +451,7 @@ def test_callback_multi_list():
|
||||
|
||||
|
||||
def test_callback_multi_list_extend():
|
||||
val1 = StrOption('val1', "", callback=return_list2, callback_params={'': (['1', '2', '3'], ['4', '5'])}, multi=True)
|
||||
val1 = StrOption('val1', "", callback=return_list2, callback_params=Params((ParamValue(['1', '2', '3']), ParamValue(['4', '5']))), multi=True)
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
api = getapi(Config(maconfig))
|
||||
api.property.read_write()
|
||||
@ -470,7 +486,7 @@ def test_callback_master_and_slaves_master():
|
||||
|
||||
def test_callback_slave():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value3, callback_params={'': (['string', 'new'],)})
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value3, callback_params=Params(ParamValue(['string', 'new'])))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
@ -495,8 +511,8 @@ def test_callback_slave():
|
||||
def test_callback_master_and_slaves_master2():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, default_multi='val2')
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)})
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val3)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
@ -510,9 +526,9 @@ def test_callback_master_and_slaves_master2():
|
||||
|
||||
def test_callback_master_and_slaves_master_mandatory():
|
||||
val = StrOption('val', "", default='val')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params={'': ((val, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_index, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_index, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params=Params(ParamOption(val)), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
@ -533,9 +549,9 @@ def test_callback_master_and_slaves_master_mandatory():
|
||||
def test_callback_master_and_slaves_master_mandatory2():
|
||||
val = StrOption('val', "", default='val')
|
||||
val_ = StrOption('val_', "", default='val_')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_index, callback_params={'': ((val, False),), 'val2': ((val_, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_index, callback_params={'': ((val1, False),), 'val2': ((val_, False),)}, properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_index, callback_params={'': ((val1, False),), 'val2': ((val_, False),)}, properties=('mandatory',))
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val), {'val2': ParamOption(val_)}), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val1), {'val2': ParamOption(val_)}), properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_index, callback_params=Params(ParamOption(val1), {'val2': ParamOption(val_)}), properties=('mandatory',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, val_, interface1])
|
||||
@ -562,9 +578,9 @@ def test_callback_master_and_slaves_master_mandatory2():
|
||||
def test_callback_master_and_slaves_master_mandatory3():
|
||||
val = StrOption('val', "", default='val')
|
||||
val_ = StrOption('val_', "", default='val_')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params={'': ((val, False),), 'val': ((val_, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params=Params(ParamOption(val), {'val': ParamOption(val_)}), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, val_, interface1])
|
||||
@ -589,9 +605,9 @@ def test_callback_master_and_slaves_master_mandatory3():
|
||||
|
||||
def test_callback_master_and_slaves_master_mandatory4():
|
||||
val = StrOption('val', "", default='val')
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params={'': ((val, False),)}, properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)}, properties=('mandatory',))
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value2, callback_params=Params(ParamOption(val)), properties=('mandatory',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)), properties=('mandatory',))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
@ -614,8 +630,8 @@ def test_callback_master_and_slaves_master_mandatory4():
|
||||
def test_callback_master_and_slaves_master3():
|
||||
val1 = StrOption('val1', "", multi=True, properties=('mandatory', 'empty'))
|
||||
val2 = StrOption('val2', "", multi=True, default_multi='val2', properties=('expert',))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)})
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val3)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
@ -627,8 +643,8 @@ def test_callback_master_and_slaves_master3():
|
||||
def test_callback_master_and_slaves_master4():
|
||||
val1 = StrOption('val1', "", ['val1'], multi=True, properties=('mandatory',))
|
||||
val2 = StrOption('val2', "", multi=True, default_multi='val2', properties=('expert', 'mandatory'))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)})
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
val4 = StrOption('val4', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val3)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val4])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
@ -777,7 +793,7 @@ def test_callback_master_and_slaves():
|
||||
|
||||
def test_callback_master_and_slaves_slave_cal():
|
||||
val3 = StrOption('val3', "", multi=True)
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val3)))
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_val)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
@ -829,7 +845,7 @@ def test_callback_master_and_slaves_master_disabled():
|
||||
|
||||
def test_callback_master_and_slaves_master_callback_disabled():
|
||||
val0 = StrOption('val0', "", multi=True, properties=('disabled',))
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val0, False),)})
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val0)))
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
@ -875,7 +891,7 @@ def test_callback_master_and_slaves_slave_disabled():
|
||||
def test_callback_master_and_slaves_slave_callback_disabled():
|
||||
val0 = StrOption('val0', "", multi=True, properties=('disabled',))
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': ((val0, False),)})
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val0)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val0])
|
||||
@ -895,10 +911,10 @@ def test_callback_master_and_slaves_slave_callback_disabled():
|
||||
def test_callback_master_and_slaves_value():
|
||||
val4 = StrOption('val4', '', multi=True, default=['val10', 'val11'])
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': ((val1, False),)})
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params={'': ('yes',)})
|
||||
val5 = StrOption('val5', "", multi=True, callback=return_value, callback_params={'': ((val4, False),)})
|
||||
val6 = StrOption('val6', "", multi=True, callback=return_value, callback_params={'': ((val5, False),)})
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
||||
val3 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamValue('yes')))
|
||||
val5 = StrOption('val5', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val4)))
|
||||
val6 = StrOption('val6', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val5)))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2, val3, val5, val6])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val4])
|
||||
@ -966,7 +982,7 @@ def test_callback_master_and_slaves_value():
|
||||
|
||||
def test_callback_master():
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_value)
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val2, False),)})
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val2)))
|
||||
raises(ValueError, "MasterSlaves('val1', '', [val1, val2])")
|
||||
|
||||
|
||||
@ -974,7 +990,7 @@ def test_callback_different_type():
|
||||
val = IntOption('val', "", default=2)
|
||||
val_ = IntOption('val_', "", default=3)
|
||||
val1 = IntOption('val1', "", multi=True)
|
||||
val2 = IntOption('val2', "", multi=True, callback=return_calc, callback_params={'': ((val, False), (val1, False)), 'k': ((val_, False),)})
|
||||
val2 = IntOption('val2', "", multi=True, callback=return_calc, callback_params=Params((ParamOption(val), ParamOption(val1)), {'k': ParamOption(val_)}))
|
||||
interface1 = MasterSlaves('val1', '', [val1, val2])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val, val_])
|
||||
@ -997,7 +1013,7 @@ def test_callback_different_type():
|
||||
|
||||
def test_callback_hidden():
|
||||
opt1 = BoolOption('opt1', '')
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)})
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1)))
|
||||
od1 = OptionDescription('od1', '', [opt1], properties=('hidden',))
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1009,7 +1025,7 @@ def test_callback_hidden():
|
||||
|
||||
def test_callback_hidden_permissive():
|
||||
opt1 = BoolOption('opt1', '')
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)})
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1)))
|
||||
od1 = OptionDescription('od1', '', [opt1], properties=('hidden',))
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1022,7 +1038,7 @@ def test_callback_hidden_permissive():
|
||||
|
||||
def test_callback_hidden_permissive_callback():
|
||||
opt1 = BoolOption('opt1', '')
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, True),)})
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1, True)))
|
||||
od1 = OptionDescription('od1', '', [opt1], properties=('hidden',))
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1034,7 +1050,7 @@ def test_callback_hidden_permissive_callback():
|
||||
|
||||
def test_callback_two_disabled():
|
||||
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}, properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1)), properties=('disabled',))
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1045,7 +1061,7 @@ def test_callback_two_disabled():
|
||||
|
||||
def test_callback_two_disabled2():
|
||||
opt1 = BoolOption('opt1', '', properties=('hidden',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}, properties=('hidden',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1)), properties=('hidden',))
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1058,7 +1074,7 @@ def test_callback_two_disabled2():
|
||||
|
||||
def test_callback_calculating_invalid():
|
||||
opt1 = IntOption('opt1', '', 1)
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)})
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1)))
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1071,7 +1087,7 @@ def test_callback_calculating_invalid():
|
||||
|
||||
def test_callback_calculating_disabled():
|
||||
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)})
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1)))
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1082,7 +1098,7 @@ def test_callback_calculating_disabled():
|
||||
|
||||
def test_callback_calculating_mandatory():
|
||||
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}, properties=('mandatory',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1)), properties=('mandatory',))
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1093,7 +1109,7 @@ def test_callback_calculating_mandatory():
|
||||
|
||||
def test_callback_calculating_mandatory_multi():
|
||||
opt1 = BoolOption('opt1', '', multi=True, properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', multi=True, callback=return_value, callback_params={'': ((opt1, False),)}, properties=('mandatory',))
|
||||
opt2 = BoolOption('opt2', '', multi=True, callback=return_value, callback_params=Params(ParamOption(opt1)), properties=('mandatory',))
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1104,7 +1120,7 @@ def test_callback_calculating_mandatory_multi():
|
||||
|
||||
def test_callback_two_disabled_multi():
|
||||
opt1 = BoolOption('opt1', '', properties=('disabled',))
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params={'': ((opt1, False),)}, properties=('disabled',), multi=True)
|
||||
opt2 = BoolOption('opt2', '', callback=return_value, callback_params=Params(ParamOption(opt1)), properties=('disabled',), multi=True)
|
||||
od1 = OptionDescription('od1', '', [opt1])
|
||||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
@ -1115,7 +1131,7 @@ def test_callback_two_disabled_multi():
|
||||
|
||||
def test_callback_multi_list_params():
|
||||
val1 = StrOption('val1', "", multi=True, default=['val1', 'val2'])
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_list, callback_params={'': ((val1, False),)})
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_list, callback_params=Params(ParamOption(val1)))
|
||||
oval2 = OptionDescription('val2', '', [val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, oval2])
|
||||
api = getapi(Config(maconfig))
|
||||
@ -1125,7 +1141,7 @@ def test_callback_multi_list_params():
|
||||
|
||||
def test_callback_multi_list_params_key():
|
||||
val1 = StrOption('val1', "", multi=True, default=['val1', 'val2'])
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_list, callback_params={'value': ((val1, False),)})
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_list, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
||||
oval2 = OptionDescription('val2', '', [val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, oval2])
|
||||
api = getapi(Config(maconfig))
|
||||
@ -1135,7 +1151,7 @@ def test_callback_multi_list_params_key():
|
||||
|
||||
def test_masterslaves_callback_description():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_value, callback_params={'': ((st1, False),)})
|
||||
st2 = StrOption('st2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(st1)))
|
||||
stm = MasterSlaves('st1', '', [st1, st2])
|
||||
#stm.impl_set_group_type(groups.master)
|
||||
st = OptionDescription('st', '', [stm])
|
||||
@ -1152,13 +1168,6 @@ def test_masterslaves_callback_description():
|
||||
assert api.option('od.st.st1.st2', 0).owner.get() == owner
|
||||
|
||||
|
||||
def test_re_set_callback():
|
||||
st1 = StrOption('st1', "", multi=True)
|
||||
st2 = StrOption('st2', "", multi=True)
|
||||
st2.impl_set_callback(return_value, {'': ((st1, False),)})
|
||||
raises(ConfigError, "st2.impl_set_callback(return_value, {'': ((st1, False),)})")
|
||||
|
||||
|
||||
def test_callback_raise():
|
||||
opt1 = BoolOption('opt1', 'Option 1', callback=return_raise)
|
||||
opt2 = BoolOption('opt2', 'Option 2', callback=return_valueerror)
|
||||
|
@ -6,7 +6,7 @@ from py.test import raises
|
||||
from tiramisu.setting import owners, groups
|
||||
from tiramisu import IPOption, NetworkOption, NetmaskOption, IntOption,\
|
||||
BroadcastOption, StrOption, SymLinkOption, OptionDescription, submulti, MasterSlaves,\
|
||||
Config, getapi, undefined
|
||||
Config, getapi, undefined, Params, ParamOption
|
||||
from tiramisu.error import ConfigError, ValueWarning, PropertiesOptionError
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
import warnings
|
||||
@ -549,7 +549,7 @@ def test_consistency_network_netmask_multi_slave_callback():
|
||||
|
||||
def test_consistency_network_netmask_multi_slave_callback_value():
|
||||
a = NetworkOption('a', '', multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', callback=return_netmask2, callback_params={'': ((a, False),)}, multi=True, properties=('mandatory',))
|
||||
b = NetmaskOption('b', '', callback=return_netmask2, callback_params=Params(ParamOption(a)), multi=True, properties=('mandatory',))
|
||||
od = MasterSlaves('a', '', [a, b])
|
||||
#od.impl_set_group_type(groups.master)
|
||||
b.impl_add_consistency('network_netmask', a)
|
||||
@ -755,7 +755,7 @@ def return_val(*args, **kwargs):
|
||||
def test_consistency_with_callback():
|
||||
a = NetworkOption('a', '', default='192.168.1.0')
|
||||
b = NetmaskOption('b', '', default='255.255.255.0')
|
||||
c = IPOption('c', '', callback=return_val, callback_params={'': ((a, False),)})
|
||||
c = IPOption('c', '', callback=return_val, callback_params=Params(ParamOption(a)))
|
||||
od = OptionDescription('od', '', [a, b, c])
|
||||
c.impl_add_consistency('in_network', a, b)
|
||||
api = getapi(Config(od))
|
||||
|
@ -4,7 +4,7 @@ do_autopath()
|
||||
import warnings
|
||||
from py.test import raises
|
||||
|
||||
from tiramisu import BoolOption, StrOption, OptionDescription, MasterSlaves, Config, getapi
|
||||
from tiramisu import BoolOption, StrOption, OptionDescription, MasterSlaves, Config, getapi, Params, ParamValue, ParamOption, ParamContext
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.error import ValueWarning, ConfigError
|
||||
from tiramisu.i18n import _
|
||||
@ -112,9 +112,9 @@ def test_validator():
|
||||
|
||||
|
||||
def test_validator_params():
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params={'': ('yes',)}, default='val')
|
||||
raises(ValueError, "StrOption('opt2', '', validator=return_false, validator_params={'': ('yes',)}, default='val')")
|
||||
opt2 = StrOption('opt2', '', validator=return_false, validator_params={'': ('yes',)})
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params=Params(ParamValue('yes')), default='val')
|
||||
raises(ValueError, "StrOption('opt2', '', validator=return_false, validator_params=Params(ParamValue('yes')), default='val')")
|
||||
opt2 = StrOption('opt2', '', validator=return_false, validator_params=Params(ParamValue('yes')))
|
||||
root = OptionDescription('root', '', [opt1, opt2])
|
||||
api = getapi(Config(root))
|
||||
assert api.option('opt1').value.get() == 'val'
|
||||
@ -198,7 +198,7 @@ def test_validator_params_value_values_kwargs_empty():
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
validator=value_empty,
|
||||
validator_params={'': ((v, False),)})
|
||||
validator_params=Params(ParamOption(v)))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [v, interface1])
|
||||
@ -216,7 +216,7 @@ def test_validator_params_value_values_kwargs():
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
validator=value_values_auto,
|
||||
validator_params={'auto': ((v, False),)})
|
||||
validator_params=Params(kwargs={'auto': ParamOption(v)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [v, interface1])
|
||||
@ -233,7 +233,7 @@ def test_validator_params_value_values_kwargs_values():
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
validator=value_values_auto2,
|
||||
validator_params={'values': ((ip_admin_eth0, False),)})
|
||||
validator_params=Params(kwargs={'values': ParamOption(ip_admin_eth0)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
@ -251,7 +251,7 @@ def test_validator_params_value_values_kwargs2():
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
validator=value_values_index2,
|
||||
validator_params={'': (['val1'],), 'index': ((ip_admin_eth0, False),)})
|
||||
validator_params=Params(ParamValue(['val1']), {'index': ParamOption(ip_admin_eth0)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
@ -268,7 +268,7 @@ def test_validator_params_value_values_kwargs_index():
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
validator=value_values_index2,
|
||||
validator_params={'index': ((ip_admin_eth0, False),)})
|
||||
validator_params=Params(kwargs={'index': ParamOption(ip_admin_eth0)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
@ -281,7 +281,7 @@ def test_validator_params_value_values_kwargs_index():
|
||||
|
||||
|
||||
def test_validator_params_context():
|
||||
opt1 = StrOption('opt1', '', validator=is_context, validator_params={'': ((None,),)}, default='val')
|
||||
opt1 = StrOption('opt1', '', validator=is_context, validator_params=Params(ParamContext()), default='val')
|
||||
root = OptionDescription('root', '', [opt1])
|
||||
api = getapi(Config(root))
|
||||
assert 'validator' in api.property.get()
|
||||
@ -291,7 +291,7 @@ def test_validator_params_context():
|
||||
|
||||
def test_validator_params_context_value():
|
||||
opt1 = StrOption('opt1', '', 'yes')
|
||||
opt2 = StrOption('opt2', '', validator=valid_from_config, validator_params={'': ((None,),)}, default='val')
|
||||
opt2 = StrOption('opt2', '', validator=valid_from_config, validator_params=Params(ParamContext()), default='val')
|
||||
root = OptionDescription('root', '', [opt1, opt2])
|
||||
api = getapi(Config(root))
|
||||
assert api.option('opt1').value.get() == 'yes'
|
||||
@ -301,8 +301,8 @@ def test_validator_params_context_value():
|
||||
|
||||
|
||||
def test_validator_params_key():
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params={'param': ('yes',)}, default='val')
|
||||
raises(ConfigError, "StrOption('opt2', '', validator=return_true, validator_params={'param_unknown': ('yes',)}, default='val')")
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params=Params(kwargs={'param': ParamValue('yes')}), default='val')
|
||||
raises(ConfigError, "StrOption('opt2', '', validator=return_true, validator_params=Params(kwargs={'param_unknown': ParamValue('yes')}), default='val')")
|
||||
root = OptionDescription('root', '', [opt1])
|
||||
api = getapi(Config(root))
|
||||
assert api.option('opt1').value.get() == 'val'
|
||||
@ -310,7 +310,7 @@ def test_validator_params_key():
|
||||
|
||||
def test_validator_params_option():
|
||||
opt0 = StrOption('opt0', '', default='yes')
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params={'': ((opt0, False),)}, default='val')
|
||||
opt1 = StrOption('opt1', '', validator=return_true, validator_params=Params(ParamOption(opt0)), default='val')
|
||||
r = OptionDescription('root', '', [opt0, opt1])
|
||||
api = getapi(Config(r))
|
||||
assert api.option('opt1').value.get() == 'val'
|
||||
@ -458,7 +458,7 @@ def test_validator_slave_param():
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
validator=return_true,
|
||||
validator_params={'param': ((ip_admin_eth0, False),)})
|
||||
validator_params=Params(kwargs={'param': ParamOption(ip_admin_eth0)}))
|
||||
interface1 = MasterSlaves('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
#interface1.impl_set_group_type(groups.master)
|
||||
root = OptionDescription('root', '', [interface1])
|
||||
@ -475,7 +475,7 @@ def test_validator_dependencies():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0',
|
||||
"masque du sous-reseau",
|
||||
validator=return_true,
|
||||
validator_params={'param': ((ip_admin_eth0, False),)})
|
||||
validator_params=Params(kwargs={'param': ParamOption(ip_admin_eth0)}))
|
||||
opt2 = StrOption('opt2', '', validator=return_false)
|
||||
root = OptionDescription('root', '', [ip_admin_eth0, netmask_admin_eth0, opt2])
|
||||
api = getapi(Config(root))
|
||||
|
@ -7,7 +7,7 @@ from py.test import raises
|
||||
from tiramisu.api import TIRAMISU_VERSION
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import StrOption, IntOption, OptionDescription, submulti, MasterSlaves, Config, \
|
||||
MetaConfig, getapi, undefined
|
||||
MetaConfig, getapi, undefined, Params, ParamOption
|
||||
from tiramisu.error import SlaveError
|
||||
|
||||
|
||||
@ -372,7 +372,7 @@ def test__master_is_submulti():
|
||||
|
||||
def test_callback_submulti():
|
||||
multi = StrOption('multi', '', multi=submulti)
|
||||
multi2 = StrOption('multi2', '', multi=submulti, callback=return_val, callback_params={'': ((multi, False),)})
|
||||
multi2 = StrOption('multi2', '', multi=submulti, callback=return_val, callback_params=Params(ParamOption(multi)))
|
||||
od = OptionDescription('multi', '', [multi, multi2])
|
||||
api = getapi(Config(od))
|
||||
api.property.read_write()
|
||||
|
@ -93,7 +93,7 @@ def test_symlink_getcallback():
|
||||
api = getapi(Config(descr))
|
||||
api.property.read_write()
|
||||
assert boolopt.impl_has_callback() == linkopt.impl_has_callback() == True
|
||||
assert boolopt.impl_get_callback() == linkopt.impl_get_callback() == (return_value, {})
|
||||
assert boolopt.impl_get_callback() == linkopt.impl_get_callback() == (return_value, None)
|
||||
|
||||
|
||||
def test_symlink_requires():
|
||||
|
Reference in New Issue
Block a user