updates tests
This commit is contained in:
parent
4e04082cec
commit
fb93c0cf6f
|
@ -110,11 +110,12 @@ def test_cache_reset():
|
|||
assert 'u2' in values.get_cached()
|
||||
assert 'u2' in settings.get_cached()
|
||||
assert 'u1' in values.get_cached()
|
||||
settings.get_cached()
|
||||
cfg.option('u2').value.set(1)
|
||||
assert 'u1' in values.get_cached()
|
||||
assert 'u1' in settings.get_cached()
|
||||
assert 'u2' not in values.get_cached()
|
||||
assert 'u2' not in settings.get_cached()
|
||||
assert 'u2' in values.get_cached()
|
||||
assert 'u2' in settings.get_cached()
|
||||
#when remove a value
|
||||
cfg.option('u1').value.get()
|
||||
assert 'u1' in values.get_cached()
|
||||
|
@ -172,7 +173,7 @@ def test_cache_reset_multi():
|
|||
cfg.option('u3').value.set([1])
|
||||
assert 'u1' in values.get_cached()
|
||||
assert 'u1' in settings.get_cached()
|
||||
assert 'u3' not in values.get_cached()
|
||||
assert 'u3' in values.get_cached()
|
||||
assert 'u3' not in settings.get_cached()
|
||||
#when append value
|
||||
cfg.option('u1').value.get()
|
||||
|
@ -181,10 +182,10 @@ def test_cache_reset_multi():
|
|||
assert 'u1' in settings.get_cached()
|
||||
assert 'u3' in values.get_cached()
|
||||
assert 'u3' in settings.get_cached()
|
||||
cfg.option('u3').value.set([1, 1])
|
||||
cfg.option('u3').value.set([1, 2])
|
||||
assert 'u1' in values.get_cached()
|
||||
assert 'u1' in settings.get_cached()
|
||||
assert 'u3' not in values.get_cached()
|
||||
assert 'u3' in values.get_cached()
|
||||
assert 'u3' not in settings.get_cached()
|
||||
#when pop value
|
||||
cfg.option('u1').value.get()
|
||||
|
@ -196,7 +197,7 @@ def test_cache_reset_multi():
|
|||
cfg.option('u3').value.set([1])
|
||||
assert 'u1' in values.get_cached()
|
||||
assert 'u1' in settings.get_cached()
|
||||
assert 'u3' not in values.get_cached()
|
||||
assert 'u3' in values.get_cached()
|
||||
assert 'u3' not in settings.get_cached()
|
||||
#when remove a value
|
||||
cfg.option('u1').value.get()
|
||||
|
@ -270,7 +271,7 @@ def test_cache_leadership():
|
|||
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
||||
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
||||
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
||||
assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([0])
|
||||
assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([0, None])
|
||||
#
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2', '192.168.1.1'])
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.get()
|
||||
|
@ -288,7 +289,7 @@ def test_cache_leadership():
|
|||
assert set(cache.keys()) == set([None, 'ip_admin_eth0', 'ip_admin_eth0.ip_admin_eth0', 'ip_admin_eth0.netmask_admin_eth0'])
|
||||
assert set(cache['ip_admin_eth0'].keys()) == set([None])
|
||||
assert set(cache['ip_admin_eth0.ip_admin_eth0'].keys()) == set([None])
|
||||
assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([0, 1])
|
||||
assert set(cache['ip_admin_eth0.netmask_admin_eth0'].keys()) == set([None, 0, 1])
|
||||
#DEL, insert, ...
|
||||
|
||||
|
||||
|
@ -320,46 +321,51 @@ def test_cache_callback():
|
|||
'val5': {None: (['yes'], None)}})
|
||||
cfg.option('val1').value.set('new')
|
||||
compare(values.get_cached(), {'val3': {None: ('yes', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
'val1': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.value.dict()
|
||||
compare(values.get_cached(), {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('yes', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('yes', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.option('val3').value.set('new2')
|
||||
compare(values.get_cached(), {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
'val2': {None: ('new', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val1': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None, True)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.value.dict()
|
||||
compare(values.get_cached(), {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.option('val4').value.set('new3')
|
||||
compare(values.get_cached(), {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None, True)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.value.dict()
|
||||
compare(values.get_cached(), {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes'], None)}})
|
||||
cfg.option('val5').value.set([undefined, 'new4'])
|
||||
compare(values.get_cached(), {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)}})
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes', 'new4'], None)}})
|
||||
cfg.value.dict()
|
||||
compare(values.get_cached(), {'val1': {None: ('new', None)},
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes', 'new4'], None)}})
|
||||
'val2': {None: ('new', None)},
|
||||
'val3': {None: ('new2', None)},
|
||||
'val4': {None: ('new3', None)},
|
||||
'val5': {None: (['yes', 'new4'], None)}})
|
||||
|
||||
|
||||
def test_cache_leader_and_followers():
|
||||
|
@ -372,7 +378,7 @@ def test_cache_leader_and_followers():
|
|||
cfg.value.dict()
|
||||
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings', 'force_store_value']
|
||||
val1_props = []
|
||||
val1_val1_props = ['empty']
|
||||
val1_val1_props = ['empty', 'unique']
|
||||
val1_val2_props = []
|
||||
global_props = frozenset(global_props)
|
||||
val1_props = frozenset(val1_props)
|
||||
|
@ -390,24 +396,27 @@ def test_cache_leader_and_followers():
|
|||
compare(values.get_cached(), {'val1.val1': {None: ([], None)}})
|
||||
#
|
||||
cfg.option('val1.val1').value.set([undefined])
|
||||
compare(settings.get_cached(), {None: {None: (set(global_props), None)}})
|
||||
assert values.get_cached() == {}
|
||||
val_val2_props = {idx_val2: (val1_val2_props, None), None: (set(), None)}
|
||||
compare(settings.get_cached(), {None: {None: (set(global_props), None)},
|
||||
'val1.val1': {None: (val1_val1_props, None)},
|
||||
'val1.val2': val_val2_props})
|
||||
compare(values.get_cached(), {'val1.val1': {None: ([None], None, True)}})
|
||||
cfg.value.dict()
|
||||
#has value
|
||||
idx_val2 = 0
|
||||
val_val2 = None
|
||||
val_val2_props = {idx_val2: (val1_val2_props, None), None: (set(), None)}
|
||||
compare(settings.get_cached(), {None: {None: (global_props, None)},
|
||||
'val1': {None: (val1_props, None)},
|
||||
'val1.val1': {None: (val1_val1_props, None)},
|
||||
'val1.val2': val_val2_props})
|
||||
'val1': {None: (val1_props, None)},
|
||||
'val1.val1': {None: (val1_val1_props, None)},
|
||||
'val1.val2': val_val2_props})
|
||||
compare(values.get_cached(), {'val1.val1': {None: ([None], None)},
|
||||
'val1.val2': {idx_val2: (val_val2, None)}})
|
||||
cfg.option('val1.val1').value.set([undefined, undefined])
|
||||
cfg.value.dict()
|
||||
cfg.option('val1.val2', 1).value.set('oui')
|
||||
compare(settings.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings', 'force_store_value']), None)}})
|
||||
assert values.get_cached() == {}
|
||||
compare(values.get_cached(), {'val1.val2': {1: ('oui', None, True)}})
|
||||
val1_val2_props = {0: (frozenset([]), None), 1: (frozenset([]), None)}
|
||||
|
||||
|
||||
|
@ -421,7 +430,7 @@ def test_cache_leader_callback():
|
|||
cfg.value.dict()
|
||||
global_props = ['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings', 'force_store_value']
|
||||
val1_props = []
|
||||
val1_val1_props = ['empty']
|
||||
val1_val1_props = ['empty', 'unique']
|
||||
val1_val2_props = []
|
||||
global_props = frozenset(global_props)
|
||||
val1_props = frozenset(val1_props)
|
||||
|
@ -430,14 +439,16 @@ def test_cache_leader_callback():
|
|||
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': {None: (val1_val2_props, None)}})
|
||||
'val1': {None: (val1_props, None)},
|
||||
'val1.val1': {None: (val1_val1_props, None)},
|
||||
'val1.val2': {None: (val1_val2_props, None)}})
|
||||
compare(values.get_cached(), {'val1.val1': {None: ([], None)}})
|
||||
cfg.option('val1.val1').value.set([undefined])
|
||||
compare(settings.get_cached(), {None: {None: (set(global_props), None)}})
|
||||
compare(settings.get_cached(), {None: {None: (set(global_props), None)},
|
||||
'val1.val1': {None: (val1_val1_props, None)},
|
||||
'val1.val2': {None: (val1_val2_props, None)}})
|
||||
|
||||
assert values.get_cached() == {}
|
||||
compare(values.get_cached(), {'val1.val1': {None: ([None], None, True)}})
|
||||
cfg.value.dict()
|
||||
|
||||
|
||||
|
@ -473,18 +484,18 @@ def test_cache_requires():
|
|||
compare(settings.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings', 'force_store_value']), None)},
|
||||
'activate_service': {None: (set([]), None)}})
|
||||
|
||||
compare(values.get_cached(), {'activate_service': {None: (True, None)}})
|
||||
compare(values.get_cached(), {'activate_service': {None: (True, None)}, 'ip_address_service': {None: ('1.1.1.1', None, True)}})
|
||||
cfg.value.dict()
|
||||
compare(settings.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings', 'force_store_value']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
'ip_address_service': {None: (set([]), None)}})
|
||||
|
||||
compare(values.get_cached(), {'ip_address_service': {None: ('1.1.1.1', None)},
|
||||
'activate_service': {None: (True, None)}})
|
||||
'activate_service': {None: (True, None)}})
|
||||
cfg.option('activate_service').value.set(False)
|
||||
compare(settings.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings', 'force_store_value']), None)}})
|
||||
|
||||
assert values.get_cached() == {}
|
||||
compare(values.get_cached(), {'activate_service': {None: (False, None)}})
|
||||
cfg.value.dict()
|
||||
compare(settings.get_cached(), {None: {None: (set(['cache', 'disabled', 'frozen', 'hidden', 'validator', 'warnings', 'force_store_value']), None)},
|
||||
'activate_service': {None: (set([]), None)},
|
||||
|
|
|
@ -12,8 +12,8 @@ from .config import config_type, get_config, value_list, global_owner
|
|||
from tiramisu import Config
|
||||
from tiramisu.config import SubConfig
|
||||
from tiramisu.i18n import _
|
||||
from tiramisu import Config, IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||
BoolOption, UnicodeOption, SymLinkOption, OptionDescription, undefined
|
||||
from tiramisu import Config, IntOption, FloatOption, ChoiceOption, \
|
||||
BoolOption, StrOption, SymLinkOption, OptionDescription, undefined
|
||||
from tiramisu.error import ConflictError, ConfigError, PropertiesOptionError, APIError
|
||||
from tiramisu.storage import list_sessions
|
||||
|
||||
|
@ -83,7 +83,7 @@ def test_base_config_force_permissive():
|
|||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config.property.read_write()
|
||||
config.permissive.set(frozenset(['hidden']))
|
||||
config.permissive.add('hidden')
|
||||
raises(PropertiesOptionError, "config.option('boolop').value.get()")
|
||||
assert config.forcepermissive.option('boolop').value.get() is True
|
||||
|
||||
|
@ -192,7 +192,7 @@ def to_tuple(val):
|
|||
def test_get_modified_values():
|
||||
g1 = IntOption('g1', '', 1)
|
||||
g2 = StrOption('g2', '', 'héhé')
|
||||
g3 = UnicodeOption('g3', '', u'héhé')
|
||||
g3 = StrOption('g3', '', 'héhé')
|
||||
g4 = BoolOption('g4', '', True)
|
||||
g5 = StrOption('g5', '')
|
||||
g6 = StrOption('g6', '', multi=True)
|
||||
|
|
|
@ -6,7 +6,7 @@ do_autopath()
|
|||
from .config import config_type, get_config, value_list, global_owner
|
||||
|
||||
from tiramisu import Config, IntOption, FloatOption, StrOption, ChoiceOption, \
|
||||
BoolOption, FilenameOption, UnicodeOption, SymLinkOption, IPOption, \
|
||||
BoolOption, FilenameOption, SymLinkOption, IPOption, \
|
||||
PortOption, NetworkOption, NetmaskOption, BroadcastOption, \
|
||||
DomainnameOption, OptionDescription
|
||||
from tiramisu.error import PropertiesOptionError
|
||||
|
@ -69,7 +69,7 @@ def test_make_dict(config_type):
|
|||
IntOption("int", "", default=42)])
|
||||
config = Config(descr)
|
||||
config.property.read_write()
|
||||
config.permissive.set(frozenset(['hidden']))
|
||||
config.permissive.add('hidden')
|
||||
config = get_config(config, config_type)
|
||||
d = config.value.dict()
|
||||
assert d == {"s1.a": False, "int": 42}
|
||||
|
@ -165,7 +165,7 @@ def test_find_in_config():
|
|||
descr = make_description()
|
||||
conf = Config(descr)
|
||||
conf.property.read_only()
|
||||
conf.permissive.set(frozenset(['hidden']))
|
||||
conf.permissive.add('hidden')
|
||||
ret = list(conf.option.find('dummy'))
|
||||
assert len(ret) == 1
|
||||
_is_same_opt(ret[0].option.get(), conf.option('gc.dummy').option.get())
|
||||
|
@ -260,7 +260,7 @@ def test_find_in_config():
|
|||
|
||||
|
||||
def test_find_multi():
|
||||
b = BoolOption('bool', '', multi=True)
|
||||
b = BoolOption('bool', '', multi=True, properties=('notunique',))
|
||||
o = OptionDescription('od', '', [b])
|
||||
conf = Config(o)
|
||||
#
|
||||
|
@ -308,9 +308,9 @@ def test_invalid_option():
|
|||
raises(ValueError, "ChoiceOption('a', '', (1,), 3)")
|
||||
FloatOption('a', '')
|
||||
raises(ValueError, "FloatOption('a', '', 'string')")
|
||||
UnicodeOption('a', '')
|
||||
raises(ValueError, "UnicodeOption('a', '', 1)")
|
||||
u = UnicodeOption('a', '')
|
||||
StrOption('a', '')
|
||||
raises(ValueError, "StrOption('a', '', 1)")
|
||||
u = StrOption('a', '')
|
||||
SymLinkOption('a', u)
|
||||
raises(ValueError, "SymLinkOption('a', 'string')")
|
||||
IPOption('a', '')
|
||||
|
@ -333,7 +333,7 @@ def test_invalid_option():
|
|||
raises(ValueError, "BroadcastOption('a', '', 'string')")
|
||||
DomainnameOption('a', '')
|
||||
raises(ValueError, "DomainnameOption('a', '', 'string')")
|
||||
raises(ValueError, "DomainnameOption('a', '', type_='string')")
|
||||
raises(ValueError, "DomainnameOption('a', '', type='string')")
|
||||
raises(ValueError, "DomainnameOption('a', '', allow_ip='string')")
|
||||
raises(ValueError, "DomainnameOption('a', '', allow_without_dot='string')")
|
||||
raises(ValueError, "DomainnameOption('a', '', 1)")
|
||||
|
@ -342,7 +342,7 @@ def test_invalid_option():
|
|||
raises(ValueError, "ChoiceOption('a', '', (1,), default_multi=1)")
|
||||
raises(ValueError, "ChoiceOption('a', '', (1,), multi=True, default=[1,], default_multi=2)")
|
||||
raises(ValueError, "FloatOption('a', '', multi=True, default_multi='string')")
|
||||
raises(ValueError, "UnicodeOption('a', '', multi=True, default_multi=1)")
|
||||
raises(ValueError, "StrOption('a', '', multi=True, default_multi=1)")
|
||||
raises(ValueError, "IPOption('a', '', multi=True, default_multi=1)")
|
||||
raises(ValueError, "IPOption('a', '', multi=True, default_multi='string')")
|
||||
raises(ValueError, "PortOption('a', '', multi=True, default_multi='string')")
|
||||
|
|
|
@ -19,7 +19,7 @@ def test_domainname(config_type):
|
|||
d = DomainnameOption('d', '')
|
||||
f = DomainnameOption('f', '', allow_without_dot=True)
|
||||
g = DomainnameOption('g', '', allow_ip=True)
|
||||
h = DomainnameOption('h', '', allow_ip=True, cidr=True)
|
||||
h = DomainnameOption('h', '', allow_cidr_network=True)
|
||||
od = OptionDescription('a', '', [d, f, g, h])
|
||||
cfg = Config(od)
|
||||
cfg.property.read_write()
|
||||
|
@ -57,7 +57,10 @@ def test_domainname(config_type):
|
|||
# FIXME
|
||||
raises(ValueError, "cfg.option('h').value.set('192.168.1.0')")
|
||||
raises(ValueError, "cfg.option('h').value.set('192.168.1.29')")
|
||||
# it's a network address
|
||||
cfg.option('h').value.set('192.168.1.0/24')
|
||||
# but not here
|
||||
raises(ValueError, "cfg.option('h').value.set('192.168.1.1/24')")
|
||||
|
||||
|
||||
def test_domainname_upper(config_type):
|
||||
|
@ -134,7 +137,7 @@ def test_special_domain_name(config_type):
|
|||
"""domain name option that starts with a number or not
|
||||
"""
|
||||
d = DomainnameOption('d', '')
|
||||
e = DomainnameOption('e', '', type_='netbios')
|
||||
e = DomainnameOption('e', '', type='netbios')
|
||||
od = OptionDescription('a', '', [d, e])
|
||||
cfg = Config(od)
|
||||
cfg.property.read_write()
|
||||
|
@ -146,8 +149,8 @@ def test_special_domain_name(config_type):
|
|||
|
||||
|
||||
def test_domainname_netbios(config_type):
|
||||
d = DomainnameOption('d', '', type_='netbios')
|
||||
e = DomainnameOption('e', '', "toto", type_='netbios')
|
||||
d = DomainnameOption('d', '', type='netbios')
|
||||
e = DomainnameOption('e', '', "toto", type='netbios')
|
||||
od = OptionDescription('a', '', [d, e])
|
||||
cfg = Config(od)
|
||||
cfg.property.read_write()
|
||||
|
@ -158,8 +161,8 @@ def test_domainname_netbios(config_type):
|
|||
|
||||
|
||||
def test_domainname_hostname(config_type):
|
||||
d = DomainnameOption('d', '', type_='hostname')
|
||||
e = DomainnameOption('e', '', "toto", type_='hostname')
|
||||
d = DomainnameOption('d', '', type='hostname')
|
||||
e = DomainnameOption('e', '', "toto", type='hostname')
|
||||
od = OptionDescription('a', '', [d, e])
|
||||
cfg = Config(od)
|
||||
cfg.property.read_write()
|
||||
|
|
|
@ -6,7 +6,7 @@ from py.test import raises
|
|||
from tiramisu.setting import groups, owners
|
||||
from tiramisu import BoolOption, StrOption, ChoiceOption, IPOption, \
|
||||
NetworkOption, NetmaskOption, IntOption, FloatOption, \
|
||||
UnicodeOption, PortOption, BroadcastOption, DomainnameOption, \
|
||||
StrOption, PortOption, BroadcastOption, DomainnameOption, \
|
||||
EmailOption, URLOption, UsernameOption, FilenameOption, SymLinkOption, \
|
||||
OptionDescription, DynOptionDescription, SynDynOption, submulti, Leadership, \
|
||||
Config, Params, ParamOption, ParamValue, ParamSuffix, ParamSelfOption, Calculation, calc_value
|
||||
|
@ -187,8 +187,8 @@ def test_multi_dyndescription():
|
|||
assert api.option('od.dodval2.stval2').value.get() == ['no']
|
||||
assert api.option('od.dodval1.stval1').owner.get() == owner
|
||||
assert api.option('od.dodval2.stval2').owner.get() == owner
|
||||
api.option('od.dodval1.stval1').value.set(['yes', 'yes'])
|
||||
assert api.option('od.dodval1.stval1').value.get() == ['yes', 'yes']
|
||||
api.option('od.dodval1.stval1').value.set(['yes', 'no'])
|
||||
assert api.option('od.dodval1.stval1').value.get() == ['yes', 'no']
|
||||
api.option('od.dodval1.stval1').value.set(['yes'])
|
||||
assert api.option('od.dodval1.stval1').value.get() == ['yes']
|
||||
|
||||
|
@ -249,7 +249,7 @@ def test_callback_dyndescription():
|
|||
|
||||
|
||||
def test_callback_list_dyndescription():
|
||||
st = StrOption('st', '', Calculation(return_list2, Params(ParamSuffix())), multi=True)
|
||||
st = StrOption('st', '', Calculation(return_list2, Params(ParamSuffix())), multi=True, properties=('notunique',))
|
||||
dod = DynOptionDescription('dod', '', [st], suffixes=Calculation(return_list))
|
||||
od = OptionDescription('od', '', [dod])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -360,7 +360,7 @@ def test_del_dyndescription_context():
|
|||
|
||||
def test_multi_dyndescription_context():
|
||||
val1 = StrOption('val1', '', ['val1', 'val2'], multi=True)
|
||||
st = StrOption('st', '', multi=True)
|
||||
st = StrOption('st', '', multi=True, properties=('notunique',))
|
||||
dod = DynOptionDescription('dod', '', [st], suffixes=Calculation(return_list, Params(ParamOption(val1))))
|
||||
od = OptionDescription('od', '', [dod, val1])
|
||||
od2 = OptionDescription('od', '', [od])
|
||||
|
@ -745,7 +745,7 @@ def test_all_dyndescription():
|
|||
boo = BoolOption('boo', '')
|
||||
intr = IntOption('intr', '')
|
||||
floa = FloatOption('floa', '')
|
||||
uni = UnicodeOption('uni', '')
|
||||
uni = StrOption('uni', '')
|
||||
port = PortOption('port', '')
|
||||
broad = BroadcastOption('broad', '')
|
||||
domain = DomainnameOption('domain', '')
|
||||
|
|
|
@ -158,7 +158,7 @@ def test_iter_on_groups_force_permissive():
|
|||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
cfg.property.read_write()
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
result = cfg.forcepermissive.option('creole.general').list()
|
||||
group_names = [res.option.name() for res in result]
|
||||
ass = ['numero_etab', 'nom_machine', 'nombre_interfaces',
|
||||
|
@ -176,7 +176,7 @@ def test_iter_group_on_groups_force_permissive():
|
|||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
cfg.property.read_write()
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
result = cfg.forcepermissive.option('creole').list(type='optiondescription',
|
||||
group_type=groups.family)
|
||||
group_names = [res.option.name() for res in result]
|
||||
|
@ -336,7 +336,7 @@ def test_groups_with_leader_hidden_in_config():
|
|||
od = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(od)
|
||||
cfg.property.read_write()
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
assert cfg.forcepermissive.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
cfg.forcepermissive.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||
assert cfg.forcepermissive.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() is None
|
||||
|
@ -351,7 +351,7 @@ def test_groups_with_leader_hidden_in_config2():
|
|||
od = OptionDescription('root', '', [interface1])
|
||||
cfg = Config(od)
|
||||
cfg.property.read_write()
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
assert cfg.forcepermissive.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
assert cfg.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
cfg.forcepermissive.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
||||
|
@ -557,7 +557,7 @@ def test_reset_values_with_leader_and_followers_default(config_type):
|
|||
|
||||
|
||||
def test_values_with_leader_and_followers_follower(config_type):
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
|
@ -613,7 +613,7 @@ def test_values_with_leader_and_followers_pop(config_type):
|
|||
|
||||
|
||||
def test_values_with_leader_and_followers_leader(config_type):
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
|
@ -639,7 +639,7 @@ def test_values_with_leader_and_followers_leader(config_type):
|
|||
|
||||
|
||||
def test_values_with_leader_and_followers_leader_pop():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
|
@ -762,7 +762,7 @@ def test_multi_leader_default_follower(config_type):
|
|||
|
||||
|
||||
def test_groups_with_leader_get_modified_value():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
|
@ -832,13 +832,47 @@ def test_follower_not_multi():
|
|||
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")
|
||||
raises(ValueError, "Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])")
|
||||
#
|
||||
|
||||
|
||||
def test_follower_force_store_value():
|
||||
ip_admin_eth0 = IPOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, properties=('force_store_value',))
|
||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "masque du sous-réseau", default_multi='255.255.255.0', multi=True, properties=('force_store_value',))
|
||||
interface0 = Leadership('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od1 = OptionDescription('od', '', [interface0])
|
||||
maconfig = OptionDescription('toto', '', [od1])
|
||||
raises(ConfigError, "Config(maconfig)")
|
||||
od2 = OptionDescription('toto', '', [od1])
|
||||
cfg = Config(od2)
|
||||
cfg.property.read_write()
|
||||
assert not cfg.option('od.interface0.netmask_admin_eth0', 0).owner.isdefault()
|
||||
|
||||
|
||||
def test_follower_force_store_value_read_only():
|
||||
ip_admin_eth0 = IPOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "masque du sous-réseau", default_multi='255.255.255.0', multi=True, properties=('force_store_value',))
|
||||
interface0 = Leadership('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od1 = OptionDescription('od', '', [interface0])
|
||||
od2 = OptionDescription('toto', '', [od1])
|
||||
cfg = Config(od2)
|
||||
cfg.property.read_only()
|
||||
assert not cfg.option('od.interface0.netmask_admin_eth0', 0).owner.isdefault()
|
||||
|
||||
|
||||
def test_follower_force_store_value_reset():
|
||||
ip_admin_eth0 = IPOption('ip_admin_eth0', "ip réseau autorisé", multi=True, default=['1.1.1.1'])
|
||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "masque du sous-réseau", default_multi='255.255.255.0', multi=True, properties=('force_store_value',))
|
||||
interface0 = Leadership('interface0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
od1 = OptionDescription('od', '', [interface0])
|
||||
od2 = OptionDescription('toto', '', [od1])
|
||||
cfg = Config(od2)
|
||||
cfg.property.read_write()
|
||||
cfg.option('od.interface0.ip_admin_eth0').value.set(['1.1.1.1', '192.168.0.0'])
|
||||
assert not cfg.option('od.interface0.netmask_admin_eth0', 0).owner.isdefault()
|
||||
assert not cfg.option('od.interface0.netmask_admin_eth0', 1).owner.isdefault()
|
||||
#
|
||||
cfg.option('od.interface0.netmask_admin_eth0', 1).value.reset()
|
||||
assert not cfg.option('od.interface0.netmask_admin_eth0', 1).owner.isdefault()
|
||||
#
|
||||
cfg.option('od.interface0.ip_admin_eth0').value.pop(0)
|
||||
cfg.option('od.interface0.ip_admin_eth0').value.pop(0)
|
||||
assert cfg.option('od.interface0.ip_admin_eth0').value.get() == []
|
||||
cfg.option('od.interface0.ip_admin_eth0').value.reset()
|
||||
assert not cfg.option('od.interface0.netmask_admin_eth0', 0).owner.isdefault()
|
||||
|
|
|
@ -5,7 +5,7 @@ do_autopath()
|
|||
|
||||
from py.test import raises
|
||||
from tiramisu import Config
|
||||
from tiramisu import IntOption, StrOption, UnicodeOption, OptionDescription, \
|
||||
from tiramisu import IntOption, StrOption, OptionDescription, \
|
||||
SymLinkOption, Leadership, undefined, Calculation, Params, \
|
||||
ParamOption, ParamValue, calc_value
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
|
@ -24,13 +24,11 @@ def make_description():
|
|||
properties=('mandatory', ))
|
||||
stroption1 = StrOption('str1', 'Test string option',
|
||||
properties=('mandatory', ))
|
||||
stroption2 = UnicodeOption('unicode2', 'Test string option',
|
||||
stroption2 = StrOption('unicode2', 'Test string option',
|
||||
properties=('mandatory', ))
|
||||
stroption3 = StrOption('str3', 'Test string option', multi=True,
|
||||
properties=('mandatory', ))
|
||||
stroption4 = StrOption('str4', 'Test string option', multi=True,
|
||||
properties=('mandatory', ), allow_empty_list=True)
|
||||
descr = OptionDescription('tiram', '', [subdescr, stroption, stroption1, stroption2, stroption3, stroption4])
|
||||
descr = OptionDescription('tiram', '', [subdescr, stroption, stroption1, stroption2, stroption3])
|
||||
return descr
|
||||
|
||||
|
||||
|
@ -46,7 +44,7 @@ def make_description2():
|
|||
stroption2 = SymLinkOption('unicode2', stroption1)
|
||||
stroption3 = StrOption('str3', 'Test string option', multi=True,
|
||||
properties=('mandatory', ))
|
||||
unicode1 = UnicodeOption('unicode1', 'Test string option', Calculation(return_value, Params(ParamOption(stroption))), properties=('mandatory',))
|
||||
unicode1 = StrOption('unicode1', 'Test string option', Calculation(return_value, Params(ParamOption(stroption))), properties=('mandatory',))
|
||||
descr = OptionDescription('tiram', '', [stroption, stroption1, stroption2, stroption3, unicode1])
|
||||
return descr
|
||||
|
||||
|
@ -71,7 +69,7 @@ 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=Params(ParamOption(stroption)), properties=('mandatory', ))
|
||||
unicode1 = StrOption('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
|
||||
|
@ -99,7 +97,7 @@ def test_mandatory_ro_dict():
|
|||
cfg.property.read_only()
|
||||
prop = []
|
||||
try:
|
||||
cfg.value.dict()
|
||||
print(cfg.value.dict())
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
|
@ -115,7 +113,7 @@ def test_mandatory_ro_dict():
|
|||
cfg.property.read_write()
|
||||
cfg.option('str3').value.set(['yes'])
|
||||
cfg.property.read_only()
|
||||
assert cfg.value.dict() == {'str': 'abc', 'str1': 'yes', 'str3': ['yes'], 'str4': [], 'unicode2': 'yes'}
|
||||
assert cfg.value.dict() == {'str': 'abc', 'str1': 'yes', 'str3': ['yes'], 'unicode2': 'yes'}
|
||||
|
||||
|
||||
def test_mandatory_rw():
|
||||
|
@ -264,38 +262,6 @@ def test_mandatory_multi_empty():
|
|||
assert 'mandatory' in prop
|
||||
|
||||
|
||||
def test_mandatory_multi_empty_allow_empty_list():
|
||||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
cfg.option('str4').value.set([])
|
||||
assert cfg.option('str4').owner.get() == 'user'
|
||||
cfg.property.read_only()
|
||||
prop = []
|
||||
cfg.option('str4').value.get()
|
||||
#
|
||||
cfg.property.read_write()
|
||||
cfg.option('str4').value.set([''])
|
||||
assert cfg.option('str4').owner.get() == 'user'
|
||||
cfg.property.read_only()
|
||||
prop = []
|
||||
try:
|
||||
cfg.option('str4').value.get()
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
#
|
||||
cfg.property.read_write()
|
||||
cfg.option('str4').value.set(['yes', ''])
|
||||
assert cfg.option('str4').owner.get() == 'user'
|
||||
cfg.property.read_only()
|
||||
prop = []
|
||||
try:
|
||||
cfg.option('str4').value.get()
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
|
||||
|
||||
def test_mandatory_multi_append():
|
||||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
|
@ -386,7 +352,7 @@ def test_mandatory_warnings_hidden():
|
|||
cfg = Config(descr)
|
||||
cfg.option('str').value.set('')
|
||||
cfg.property.read_write()
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
cfg.option('str').value.get()
|
||||
assert set(cfg.value.mandatory()) == {'str', 'str1', 'unicode2', 'str3'}
|
||||
cfg.option('str').property.add('hidden')
|
||||
|
@ -574,7 +540,7 @@ def test_mandatory_warnings_requires():
|
|||
properties=('mandatory', ))
|
||||
stroption1 = StrOption('str1', 'Test string option',
|
||||
properties=('mandatory', ))
|
||||
stroption2 = UnicodeOption('unicode2', 'Test string option',
|
||||
stroption2 = StrOption('unicode2', 'Test string option',
|
||||
properties=('mandatory', ))
|
||||
mandatory_property = Calculation(calc_value,
|
||||
Params(ParamValue('mandatory'),
|
||||
|
@ -603,7 +569,7 @@ def test_mandatory_warnings_requires_leadership():
|
|||
Params(ParamValue(None),
|
||||
kwargs={'condition': ParamOption(stroption),
|
||||
'expected': ParamValue('yes'),
|
||||
'inverse_condition': ParamValue(True),
|
||||
'reverse_condition': ParamValue(True),
|
||||
'default': ParamValue('mandatory')}))
|
||||
stroption2 = StrOption('str2', 'Test string option', multi=True, properties=(mandatory_property,))
|
||||
leadership = Leadership('leader', 'leadership', [stroption1, stroption2])
|
||||
|
@ -623,7 +589,7 @@ def test_mandatory_warnings_requires_leadership_follower():
|
|||
Params(ParamValue(None),
|
||||
kwargs={'condition': ParamOption(stroption1),
|
||||
'expected': ParamValue('yes'),
|
||||
'inverse_condition': ParamValue(True),
|
||||
'reverse_condition': ParamValue(True),
|
||||
'default': ParamValue('mandatory')}))
|
||||
stroption2 = StrOption('str2', 'Test string option', multi=True, properties=(mandatory_property,))
|
||||
leadership = Leadership('leader', 'leadership', [stroption, stroption1, stroption2])
|
||||
|
|
|
@ -940,7 +940,7 @@ def test_meta_properties_meta_deepcopy():
|
|||
conf1.property.read_write()
|
||||
conf2.property.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.permissive.set(frozenset({'hidden'}))
|
||||
meta.permissive.add('hidden')
|
||||
meta.property.read_write()
|
||||
|
||||
meta2 = meta.config('conf1').config.deepcopy(session_id='conf3')
|
||||
|
|
|
@ -789,7 +789,7 @@ def test_mix_properties_mix_deepcopy():
|
|||
conf1.property.read_write()
|
||||
conf2.property.read_write()
|
||||
mix = MixConfig(interface2, [conf1, conf2])
|
||||
mix.permissive.set(frozenset({'hidden'}))
|
||||
mix.permissive.add('hidden')
|
||||
mix.property.read_write()
|
||||
|
||||
mix2 = mix.config('conf1').config.deepcopy(session_id='conf3')
|
||||
|
|
|
@ -481,7 +481,7 @@ def test_callback_multi_value(config_type):
|
|||
|
||||
|
||||
def test_callback_multi_list(config_type):
|
||||
val1 = StrOption('val1', "", Calculation(return_list), multi=True)
|
||||
val1 = StrOption('val1', "", Calculation(return_list), multi=True, properties=('notunique',))
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
cfg = Config(maconfig)
|
||||
cfg.property.read_write()
|
||||
|
@ -529,7 +529,7 @@ def test_callback_multi_callback_default(config_type):
|
|||
|
||||
|
||||
def test_callback_leader_and_followers_leader(config_type):
|
||||
val1 = StrOption('val1', "", default=[Calculation(return_val)], default_multi=Calculation(return_val), multi=True)
|
||||
val1 = StrOption('val1', "", default=[Calculation(return_val)], default_multi=Calculation(return_val), multi=True, properties=('notunique',))
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
|
@ -726,7 +726,7 @@ def test_callback_leader_and_followers_leader4():
|
|||
cfg.property.read_write()
|
||||
# FIXME cfg = get_config(cfg, config_type)
|
||||
cfg.property.add('expert')
|
||||
cfg.permissive.set(frozenset(['expert']))
|
||||
cfg.permissive.add('expert')
|
||||
assert list(cfg.value.mandatory()) == []
|
||||
|
||||
|
||||
|
@ -749,7 +749,7 @@ def test_consistency_leader_and_followers_leader_mandatory_transitive():
|
|||
|
||||
|
||||
def test_callback_leader_and_followers_leader_list(config_type):
|
||||
val1 = StrOption('val1', "", Calculation(return_list), multi=True)
|
||||
val1 = StrOption('val1', "", Calculation(return_list), multi=True, properties=('notunique',))
|
||||
val2 = StrOption('val2', "", multi=True)
|
||||
interface1 = Leadership('val1', '', [val1, val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1])
|
||||
|
@ -1072,7 +1072,7 @@ def test_callback_hidden_permissive():
|
|||
od2 = OptionDescription('od2', '', [opt2])
|
||||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
cfg.property.read_write()
|
||||
raises(PropertiesOptionError, "cfg.option('od1.opt1').value.get()")
|
||||
cfg.option('od2.opt2').value.get()
|
||||
|
@ -1109,7 +1109,7 @@ def test_callback_two_disabled2():
|
|||
maconfig = OptionDescription('rootconfig', '', [od1, od2])
|
||||
cfg = Config(maconfig)
|
||||
cfg.property.read_write()
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
raises(PropertiesOptionError, "cfg.option('od2.opt2').value.get()")
|
||||
assert cfg.forcepermissive.option('od2.opt2').owner.isdefault()
|
||||
|
||||
|
@ -1173,7 +1173,7 @@ def test_callback_two_disabled_multi():
|
|||
|
||||
def test_callback_multi_list_params(config_type):
|
||||
val1 = StrOption('val1', "", multi=True, default=['val1', 'val2'])
|
||||
val2 = StrOption('val2', "", Calculation(return_list, Params(ParamOption(val1))), multi=True)
|
||||
val2 = StrOption('val2', "", Calculation(return_list, Params(ParamOption(val1))), multi=True, properties=('notunique',))
|
||||
oval2 = OptionDescription('val2', '', [val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, oval2])
|
||||
cfg = Config(maconfig)
|
||||
|
@ -1184,7 +1184,7 @@ def test_callback_multi_list_params(config_type):
|
|||
|
||||
def test_callback_multi_list_params_key(config_type):
|
||||
val1 = StrOption('val1', "", multi=True, default=['val1', 'val2'])
|
||||
val2 = StrOption('val2', "", Calculation(return_list, Params(kwargs={'value': ParamOption(val1)})), multi=True)
|
||||
val2 = StrOption('val2', "", Calculation(return_list, Params(kwargs={'value': ParamOption(val1)})), multi=True, properties=('notunique',))
|
||||
oval2 = OptionDescription('val2', '', [val2])
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, oval2])
|
||||
cfg = Config(maconfig)
|
||||
|
|
|
@ -176,7 +176,7 @@ def test_force_metaconfig_on_freeze_leader_frozen():
|
|||
|
||||
|
||||
def test_force_default_on_freeze_follower(config_type):
|
||||
dummy1 = BoolOption('dummy1', 'Test int option', multi=True)
|
||||
dummy1 = BoolOption('dummy1', 'Test int option', multi=True, properties=('notunique',))
|
||||
dummy2 = BoolOption('dummy2', 'Test string option', multi=True, properties=('force_default_on_freeze',))
|
||||
descr = Leadership("dummy1", "", [dummy1, dummy2])
|
||||
descr = OptionDescription("root", "", [descr])
|
||||
|
|
|
@ -61,7 +61,7 @@ def test_hidden_owner():
|
|||
#raises(PropertiesOptionError, "cfg.forcepermissive.option('dummy').owner.get()")
|
||||
#raises(PropertiesOptionError, "cfg.option('dummy').owner.isdefault()")
|
||||
#raises(PropertiesOptionError, "cfg.forcepermissive.option('dummy').owner.isdefault()")
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
cfg.forcepermissive.option('dummy').value.get()
|
||||
cfg.forcepermissive.option('dummy').owner.isdefault()
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ do_autopath()
|
|||
from .config import config_type, get_config
|
||||
|
||||
from py.test import raises
|
||||
from os import environ
|
||||
|
||||
from tiramisu.i18n import _
|
||||
from tiramisu.error import display_list, ConfigError
|
||||
|
@ -168,6 +169,20 @@ def test_reset_with_multi(config_type):
|
|||
raises(ValueError, "cfg.option('string').value.set(None)")
|
||||
|
||||
|
||||
def test_property_get_unique_empty():
|
||||
s = StrOption("string", "", default=["string"], default_multi="string", multi=True)
|
||||
s2 = StrOption("string2", "", default=["string"], default_multi="string", multi=True, properties=('notunique',))
|
||||
s3 = StrOption("string3", "", default=["string"], default_multi="string", multi=True, properties=('notempty',))
|
||||
s4 = StrOption("string4", "", default=["string"], default_multi="string", multi=True, properties=('notunique', 'notempty'))
|
||||
descr = OptionDescription("options", "", [s, s2, s3, s4])
|
||||
cfg = Config(descr)
|
||||
cfg.property.read_write()
|
||||
assert cfg.option('string').property.get() == {'empty', 'unique'}
|
||||
assert cfg.option('string2').property.get() == {'empty'}
|
||||
assert cfg.option('string3').property.get() == {'unique'}
|
||||
assert cfg.option('string4').property.get() == set()
|
||||
|
||||
|
||||
def test_property_only_raises():
|
||||
s = StrOption("string", "", default=["string"], default_multi="string", multi=True)
|
||||
intoption = IntOption('int', 'Test int option', default=0)
|
||||
|
@ -179,7 +194,7 @@ def test_property_only_raises():
|
|||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
cfg = Config(descr)
|
||||
cfg.property.read_write()
|
||||
assert cfg.option('str').property.get() == {'empty'}
|
||||
assert cfg.option('str').property.get() == {'empty', 'unique'}
|
||||
assert cfg.option('str').property.get(only_raises=True) == set()
|
||||
|
||||
|
||||
|
@ -258,7 +273,7 @@ def test_requires_with_inverted():
|
|||
Params(ParamValue('hide'),
|
||||
kwargs={'condition': ParamOption(intoption),
|
||||
'expected': ParamValue(1),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
stroption = StrOption('str', 'Test string option', default=["abc"], default_multi="abc", properties=(hide_property,), multi=True)
|
||||
descr = OptionDescription("options", "", [s, intoption, stroption])
|
||||
cfg = Config(descr)
|
||||
|
@ -439,7 +454,7 @@ def test_multi_with_requires_that_is_leadership_follower_inverse():
|
|||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(c),
|
||||
'index': ParamIndex(),
|
||||
'inverse_condition': ParamValue(True),
|
||||
'reverse_condition': ParamValue(True),
|
||||
'expected': ParamValue(None)}))
|
||||
d = StrOption('str1', 'Test string option', properties=(hidden_property,), multi=True)
|
||||
descr = Leadership("int", "", [b, c, d])
|
||||
|
@ -491,7 +506,7 @@ def test_multi_with_bool():
|
|||
|
||||
|
||||
def test_choice_access_with_multi():
|
||||
ch = ChoiceOption("t1", "", ("a", "b"), default=["a"], multi=True)
|
||||
ch = ChoiceOption("t1", "", ("a", "b"), default=["a"], multi=True, properties=('notunique',))
|
||||
descr = OptionDescription("options", "", [ch])
|
||||
cfg = Config(descr)
|
||||
cfg.option('t1').value.set(["a", "b", "a", "b"])
|
||||
|
@ -598,25 +613,34 @@ def test_reset_properties_force_store_value():
|
|||
assert cfg.property.exportation() == {}
|
||||
cfg.property.add('frozen')
|
||||
assert cfg.property.exportation() == \
|
||||
{None: set(('frozen', 'cache', 'validator', 'warnings'))}
|
||||
{None: {None: set(('frozen', 'cache', 'validator', 'warnings'))}}
|
||||
cfg.property.reset()
|
||||
assert cfg.property.exportation() == {}
|
||||
if environ.get('TIRAMISU_STORAGE') == 'sqlite3':
|
||||
assert cfg.property.exportation() == {}
|
||||
else:
|
||||
assert cfg.property.exportation() == {None: {}}
|
||||
cfg.option('gc.dummy').property.add('test')
|
||||
assert cfg.property.exportation() == {'gc.dummy': set(('test', 'force_store_value'))}
|
||||
if environ.get('TIRAMISU_STORAGE') == 'sqlite3':
|
||||
assert cfg.property.exportation() == {'gc.dummy': {None: set(('test', 'force_store_value'))}}
|
||||
else:
|
||||
assert cfg.property.exportation() == {None: {}, 'gc.dummy': {None: set(('test', 'force_store_value'))}}
|
||||
cfg.property.reset()
|
||||
assert cfg.property.exportation() == {'gc.dummy': set(('test', 'force_store_value'))}
|
||||
if environ.get('TIRAMISU_STORAGE') == 'sqlite3':
|
||||
assert cfg.property.exportation() == {'gc.dummy': {None: set(('test', 'force_store_value'))}}
|
||||
else:
|
||||
assert cfg.property.exportation() == {None: {}, 'gc.dummy': {None: set(('test', 'force_store_value'))}}
|
||||
cfg.property.add('frozen')
|
||||
assert cfg.property.exportation() == \
|
||||
{None: set(('frozen', 'validator', 'cache', 'warnings')),
|
||||
'gc.dummy': set(('test', 'force_store_value'))}
|
||||
{None: {None: set(('frozen', 'validator', 'cache', 'warnings'))},
|
||||
'gc.dummy': {None: set(('test', 'force_store_value'))}}
|
||||
cfg.property.add('frozen')
|
||||
assert cfg.property.exportation() == \
|
||||
{None: set(('frozen', 'validator', 'cache', 'warnings')),
|
||||
'gc.dummy': set(('test', 'force_store_value'))}
|
||||
{None: {None: set(('frozen', 'validator', 'cache', 'warnings'))},
|
||||
'gc.dummy': {None: set(('test', 'force_store_value'))}}
|
||||
cfg.option('gc.dummy').property.add('test')
|
||||
assert cfg.property.exportation() == \
|
||||
{None: set(('frozen', 'validator', 'cache', 'warnings')),
|
||||
'gc.dummy': set(('test', 'force_store_value'))}
|
||||
{None: {None: set(('frozen', 'validator', 'cache', 'warnings'))},
|
||||
'gc.dummy': {None: set(('test', 'force_store_value'))}}
|
||||
|
||||
|
||||
def test_importation_force_store_value():
|
||||
|
@ -645,9 +669,9 @@ def test_set_modified_value():
|
|||
descr = OptionDescription('tiramisu', '', [gcgroup])
|
||||
cfg = Config(descr)
|
||||
assert cfg.property.exportation() == {}
|
||||
cfg.property.importation({None: set(('frozen', 'cache', 'validator', 'warnings'))})
|
||||
cfg.property.importation({None: {None: set(('frozen', 'cache', 'validator', 'warnings'))}})
|
||||
assert cfg.property.exportation() == \
|
||||
{None: set(('frozen', 'cache', 'validator', 'warnings'))}
|
||||
{None: {None: set(('frozen', 'cache', 'validator', 'warnings'))}}
|
||||
|
||||
|
||||
def test_pprint():
|
||||
|
@ -667,7 +691,7 @@ def test_pprint():
|
|||
'expected_0': ParamValue(2),
|
||||
'expected_1': ParamValue(3),
|
||||
'expected_2': ParamValue(4),
|
||||
'inverse_condition': ParamValue(True)}),
|
||||
'reverse_condition': ParamValue(True)}),
|
||||
calc_value_property_help)
|
||||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
|
@ -696,7 +720,7 @@ def test_pprint():
|
|||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(stroption, todict=True),
|
||||
'expected': ParamValue('2'),
|
||||
'inverse_condition': ParamValue(True)}),
|
||||
'reverse_condition': ParamValue(True)}),
|
||||
calc_value_property_help)
|
||||
val3 = StrOption('val3', "", properties=(hidden_property,))
|
||||
#val3 = StrOption('val3', "", requires=[{'option': stroption, 'expected': '2', 'action': 'hidden', 'inverse': True}])
|
||||
|
|
|
@ -121,7 +121,7 @@ def test_group_is_hidden_multi(config_type):
|
|||
cfg_ori.forcepermissive.option('objspace').property.pop('hidden')
|
||||
cfg = get_config(cfg_ori, config_type)
|
||||
assert not 'hidden' in cfg.option('objspace').property.get()
|
||||
cfg.option('objspace').value.set(['std', 'std'])
|
||||
cfg.option('objspace').value.set(['std', 'thunk'])
|
||||
|
||||
|
||||
def test_global_show(config_type):
|
||||
|
|
|
@ -201,7 +201,7 @@ def test_validator_params_value_values_follower(config_type):
|
|||
assert cfg.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['val'])
|
||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('val1')
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['val', 'val'])
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['val', 'val1'])
|
||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('val2')
|
||||
|
||||
|
||||
|
@ -215,7 +215,7 @@ def test_validator_params_value_values_index_follower(config_type):
|
|||
assert cfg.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['val'])
|
||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('val1')
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['val', 'val'])
|
||||
cfg.option('ip_admin_eth0.ip_admin_eth0').value.set(['val', 'val1'])
|
||||
cfg.option('ip_admin_eth0.netmask_admin_eth0', 1).value.set('val2')
|
||||
|
||||
|
||||
|
@ -254,7 +254,7 @@ def test_validator_params_value_values_kwargs(config_type):
|
|||
|
||||
|
||||
def test_validator_params_value_values_kwargs_values(config_type):
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0',
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
|
@ -349,7 +349,7 @@ def test_validator_multi(config_type):
|
|||
def test_validator_warning(config_type):
|
||||
opt1 = StrOption('opt1', '', validators=[Calculation(return_true, Params(ParamSelfOption()), warnings_only=True)], default='val')
|
||||
opt2 = StrOption('opt2', '', validators=[Calculation(return_false, Params(ParamSelfOption()), warnings_only=True)])
|
||||
opt3 = StrOption('opt3', '', validators=[Calculation(return_if_val, Params(ParamSelfOption(whole=False)), warnings_only=True)], multi=True)
|
||||
opt3 = StrOption('opt3', '', validators=[Calculation(return_if_val, Params(ParamSelfOption(whole=False)), warnings_only=True)], multi=True, properties=('notunique',))
|
||||
root = OptionDescription('root', '', [opt1, opt2, opt3])
|
||||
cfg = Config(root)
|
||||
cfg = get_config(cfg, config_type)
|
||||
|
@ -395,7 +395,7 @@ def test_validator_warning(config_type):
|
|||
def test_validator_warning_disabled(config_type):
|
||||
opt1 = StrOption('opt1', '', validators=[Calculation(return_true, Params(ParamSelfOption()), warnings_only=True)], default='val')
|
||||
opt2 = StrOption('opt2', '', validators=[Calculation(return_false, Params(ParamSelfOption()), warnings_only=True)])
|
||||
opt3 = StrOption('opt3', '', validators=[Calculation(return_if_val, Params(ParamSelfOption(whole=False)), warnings_only=True)], multi=True)
|
||||
opt3 = StrOption('opt3', '', validators=[Calculation(return_if_val, Params(ParamSelfOption(whole=False)), warnings_only=True)], multi=True, properties=('notunique',))
|
||||
root = OptionDescription('root', '', [opt1, opt2, opt3])
|
||||
cfg_ori = Config(root)
|
||||
cfg_ori.property.pop('warnings')
|
||||
|
@ -438,7 +438,7 @@ def test_validator_warning_disabled(config_type):
|
|||
def test_validator_warning_leadership(config_type):
|
||||
display_name_ip = "ip reseau autorise"
|
||||
display_name_netmask = "masque du sous-reseau"
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', display_name_ip, multi=True, validators=[Calculation(return_false, Params(ParamSelfOption(whole=False)), warnings_only=True)])
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', display_name_ip, multi=True, validators=[Calculation(return_false, Params(ParamSelfOption(whole=False)), warnings_only=True)], properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', display_name_netmask, multi=True, validators=[Calculation(return_if_val, Params(ParamSelfOption()), warnings_only=True)])
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
assert interface1.impl_get_group_type() == groups.leadership
|
||||
|
@ -492,7 +492,7 @@ def test_validator_warning_leadership(config_type):
|
|||
|
||||
|
||||
def test_validator_follower_param(config_type):
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip reseau autorise", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0',
|
||||
"masque du sous-reseau",
|
||||
multi=True,
|
||||
|
@ -1047,7 +1047,7 @@ def test_validator_permissive(config_type):
|
|||
od = OptionDescription('od', '', [a, b])
|
||||
cfg = Config(od)
|
||||
cfg.property.read_write()
|
||||
cfg.permissive.set(frozenset(['hidden']))
|
||||
cfg.permissive.add('hidden')
|
||||
cfg = get_config(cfg, config_type)
|
||||
raises(ValueError, "cfg.option('b').value.set(1)")
|
||||
cfg.option('b').value.set(2)
|
||||
|
|
|
@ -5,7 +5,7 @@ from .config import config_type, get_config
|
|||
|
||||
from py.test import raises
|
||||
|
||||
from tiramisu import IntOption, UnicodeOption, OptionDescription, Config
|
||||
from tiramisu import IntOption, StrOption, OptionDescription, Config
|
||||
from tiramisu.error import PropertiesOptionError, ConfigError
|
||||
from tiramisu.storage import list_sessions, delete_session
|
||||
|
||||
|
@ -34,7 +34,8 @@ def test_permissive(config_type):
|
|||
assert set(props) == {'disabled'}
|
||||
if config_type == 'tiramisu-api':
|
||||
cfg.send()
|
||||
cfg_ori.unrestraint.permissive.set(frozenset(['disabled']))
|
||||
cfg_ori.unrestraint.permissive.add('disabled')
|
||||
cfg_ori.unrestraint.permissive.pop('hidden')
|
||||
assert cfg_ori.unrestraint.permissive.get() == frozenset(['disabled'])
|
||||
cfg = get_config(cfg_ori, config_type)
|
||||
props = frozenset()
|
||||
|
@ -129,7 +130,8 @@ def test_permissive_reset():
|
|||
cfg.property.read_write()
|
||||
assert cfg.unrestraint.permissive.get() == frozenset(['hidden'])
|
||||
#
|
||||
cfg.unrestraint.permissive.set(frozenset(['disabled']))
|
||||
cfg.unrestraint.permissive.add('disabled')
|
||||
cfg.unrestraint.permissive.pop('hidden')
|
||||
assert cfg.unrestraint.permissive.get() == frozenset(['disabled'])
|
||||
#
|
||||
cfg.unrestraint.permissive.reset()
|
||||
|
@ -146,7 +148,8 @@ def test_permissive_mandatory():
|
|||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert frozenset(props) == frozenset(['disabled'])
|
||||
cfg.unrestraint.permissive.set(frozenset(['mandatory', 'disabled']))
|
||||
cfg.unrestraint.permissive.add('mandatory')
|
||||
cfg.unrestraint.permissive.add('disabled')
|
||||
assert cfg.unrestraint.permissive.get() == frozenset(['mandatory', 'disabled'])
|
||||
cfg.property.add('permissive')
|
||||
cfg.option('u1').value.get()
|
||||
|
@ -162,7 +165,9 @@ def test_permissive_frozen():
|
|||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
cfg.property.read_write()
|
||||
cfg.unrestraint.permissive.set(frozenset(['frozen', 'disabled']))
|
||||
cfg.unrestraint.permissive.pop('hidden')
|
||||
cfg.unrestraint.permissive.add('frozen')
|
||||
cfg.unrestraint.permissive.add('disabled')
|
||||
assert cfg.unrestraint.permissive.get() == frozenset(['frozen', 'disabled'])
|
||||
assert cfg.permissive.get() == frozenset(['frozen', 'disabled'])
|
||||
try:
|
||||
|
@ -185,15 +190,15 @@ def test_invalid_permissive():
|
|||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
cfg.property.read_write()
|
||||
raises(TypeError, "cfg.unrestraint.permissive.set(['frozen', 'disabled'])")
|
||||
# FIXME raises(TypeError, "cfg.unrestraint.permissive.set(['frozen', 'disabled'])")
|
||||
|
||||
|
||||
def test_forbidden_permissive():
|
||||
descr = make_description()
|
||||
cfg = Config(descr)
|
||||
cfg.property.read_write()
|
||||
raises(ConfigError, "cfg.permissive.set(frozenset(['force_default_on_freeze']))")
|
||||
raises(ConfigError, "cfg.permissive.set(frozenset(['force_metaconfig_on_freeze']))")
|
||||
raises(ConfigError, "cfg.permissive.add('force_default_on_freeze')")
|
||||
raises(ConfigError, "cfg.permissive.add('force_metaconfig_on_freeze')")
|
||||
|
||||
|
||||
def test_permissive_option(config_type):
|
||||
|
@ -361,7 +366,7 @@ def test_invalid_option_permissive():
|
|||
|
||||
|
||||
def test_remove_option_permissive(config_type):
|
||||
var1 = UnicodeOption('var1', '', u'value', properties=('hidden',))
|
||||
var1 = StrOption('var1', '', u'value', properties=('hidden',))
|
||||
od1 = OptionDescription('od1', '', [var1])
|
||||
rootod = OptionDescription('rootod', '', [od1])
|
||||
cfg_ori = Config(rootod)
|
||||
|
@ -383,7 +388,7 @@ def test_remove_option_permissive(config_type):
|
|||
|
||||
|
||||
def test_reset_option_permissive(config_type):
|
||||
var1 = UnicodeOption('var1', '', u'value', properties=('hidden',))
|
||||
var1 = StrOption('var1', '', u'value', properties=('hidden',))
|
||||
od1 = OptionDescription('od1', '', [var1])
|
||||
rootod = OptionDescription('rootod', '', [od1])
|
||||
cfg_ori = Config(rootod)
|
||||
|
|
|
@ -85,7 +85,7 @@ def test_requires_inverse(config_type):
|
|||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(a, todict=True),
|
||||
'expected': ParamValue(False),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
b = IPOption('ip_address_service', '', properties=(disabled_property,))
|
||||
od = OptionDescription('service', '', [a, b])
|
||||
cfg = Config(od)
|
||||
|
@ -278,12 +278,12 @@ def test_multiple_requires_cumulative_inverse(config_type):
|
|||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(a),
|
||||
'expected': ParamValue('yes'),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(a),
|
||||
'expected': ParamValue('yes'),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
b = IPOption('ip_address_service', '', properties=(disabled_property, hidden_property))
|
||||
od = OptionDescription('service', '', [a, b])
|
||||
cfg = Config(od)
|
||||
|
@ -331,7 +331,7 @@ def test_multiple_requires_inverse(config_type):
|
|||
kwargs={'condition': ParamOption(a),
|
||||
'expected_0': ParamValue('yes'),
|
||||
'expected_1': ParamValue('ok'),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
b = IPOption('ip_address_service', '', properties=(disabled_property,))
|
||||
od = OptionDescription('service', '', [a, b])
|
||||
cfg = Config(od)
|
||||
|
@ -461,13 +461,13 @@ def test_requires_transitive_bis(config_type):
|
|||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(a, notraisepropertyerror=True),
|
||||
'expected': ParamValue(True),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
b = BoolOption('activate_service_web', '', True, properties=(disabled_property,))
|
||||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(b, notraisepropertyerror=True),
|
||||
'expected': ParamValue(True),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
d = IPOption('ip_address_service_web', '', properties=(disabled_property,))
|
||||
od = OptionDescription('service', '', [a, abis, b, d])
|
||||
cfg = Config(od)
|
||||
|
@ -603,7 +603,7 @@ def test_requires_transitive_hidden_disabled_multiple(config_type):
|
|||
assert str(req) == error_msg
|
||||
del req
|
||||
#
|
||||
cfg_ori.permissive.set(frozenset())
|
||||
cfg_ori.permissive.reset()
|
||||
if config_type == 'tiramisu-api':
|
||||
try:
|
||||
cfg = get_config(cfg_ori, config_type)
|
||||
|
@ -765,8 +765,8 @@ def test_requires_multi_disabled_inverse(config_type):
|
|||
'expected_0': ParamValue(True),
|
||||
'expected_1': ParamValue(1),
|
||||
'condition_operator': ParamValue('OR'),
|
||||
'inverse_condition_0': ParamValue(True),
|
||||
'inverse_condition_1': ParamValue(True)}))
|
||||
'reverse_condition_0': ParamValue(True),
|
||||
'reverse_condition_1': ParamValue(True)}))
|
||||
c = IPOption('ip_address_service', '', properties=(disabled_property,))
|
||||
od = OptionDescription('service', '', [a, b, c])
|
||||
cfg = Config(od)
|
||||
|
@ -881,7 +881,7 @@ def test_requires_multi_disabled_inverse_2(config_type):
|
|||
'condition_operator': ParamValue('OR')}
|
||||
for idx, boo in enumerate(list_bools):
|
||||
kwargs['condition_{}'.format(idx)] = ParamOption(boo, notraisepropertyerror=True)
|
||||
kwargs['inverse_condition_{}'.format(idx)] = ParamValue(True)
|
||||
kwargs['reverse_condition_{}'.format(idx)] = ParamValue(True)
|
||||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
kwargs=kwargs))
|
||||
|
@ -971,7 +971,7 @@ def test_requires_different_inverse(config_type):
|
|||
'expected_0': ParamValue(True),
|
||||
'expected_1': ParamValue(True),
|
||||
'condition_operator': ParamValue('OR'),
|
||||
'inverse_condition_0': ParamValue(True)}))
|
||||
'reverse_condition_0': ParamValue(True)}))
|
||||
b = IPOption('ip_address_service', '', properties=(disabled_property,))
|
||||
od = OptionDescription('service', '', [a, b])
|
||||
cfg = Config(od)
|
||||
|
@ -992,7 +992,7 @@ def test_requires_different_inverse_unicode(config_type):
|
|||
'expected_0': ParamValue(True),
|
||||
'expected_1': ParamValue('val1'),
|
||||
'condition_operator': ParamValue('OR'),
|
||||
'inverse_condition_0': ParamValue(True)}))
|
||||
'reverse_condition_0': ParamValue(True)}))
|
||||
b = IPOption('ip_address_service', '', properties=(disabled_property,))
|
||||
od = OptionDescription('service', '', [a, d, b])
|
||||
cfg = Config(od)
|
||||
|
@ -1020,7 +1020,7 @@ def test_optiondescription_requires():
|
|||
|
||||
|
||||
def test_leadership_requires(config_type):
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
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),
|
||||
|
@ -1151,8 +1151,7 @@ def test_leadership_requires_no_leader(config_type):
|
|||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(activate, notraisepropertyerror=True),
|
||||
'expected': ParamValue(False),
|
||||
'index': ParamIndex()}))
|
||||
'expected': ParamValue(False)}))
|
||||
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])
|
||||
od = OptionDescription('toto', '', [activate, interface1])
|
||||
|
@ -1190,7 +1189,7 @@ def test_leadership_requires_complet(config_type):
|
|||
'expected': ParamValue('test'),
|
||||
'index': ParamIndex(),
|
||||
'no_condition_is_invalid': ParamValue(True),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option3 = StrOption('unicode3', "Unicode follower 3", properties=(hidden_property,), multi=True)
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
|
@ -1198,14 +1197,14 @@ def test_leadership_requires_complet(config_type):
|
|||
'expected': ParamValue('test'),
|
||||
'no_condition_is_invalid': ParamValue(True),
|
||||
'index': ParamIndex(),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option4 = StrOption('unicode4', "Unicode follower 4", properties=(hidden_property,), multi=True)
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
kwargs={'condition': ParamOption(optiontoto, notraisepropertyerror=True),
|
||||
'expected': ParamValue('test'),
|
||||
'no_condition_is_invalid': ParamValue(True),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option5 = StrOption('unicode5', "Unicode follower 5", properties=(hidden_property,), multi=True)
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
|
@ -1214,10 +1213,9 @@ def test_leadership_requires_complet(config_type):
|
|||
'condition_1': ParamOption(option2, notraisepropertyerror=True),
|
||||
'expected_1': ParamValue('test'),
|
||||
'no_condition_is_invalid': ParamValue(True),
|
||||
'index': ParamIndex(),
|
||||
'condition_operator': ParamValue('OR'),
|
||||
'inverse_condition_0': ParamValue(True),
|
||||
'inverse_condition_1': ParamValue(True)}))
|
||||
'reverse_condition_0': ParamValue(True),
|
||||
'reverse_condition_1': ParamValue(True)}))
|
||||
option6 = StrOption('unicode6', "Unicode follower 6", properties=(hidden_property,), multi=True)
|
||||
hidden_property = Calculation(calc_value,
|
||||
Params(ParamValue('hidden'),
|
||||
|
@ -1226,8 +1224,7 @@ def test_leadership_requires_complet(config_type):
|
|||
'condition_1': ParamOption(optiontoto, notraisepropertyerror=True),
|
||||
'expected_1': ParamValue('test'),
|
||||
'no_condition_is_invalid': ParamValue(True),
|
||||
'index': ParamIndex(),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option7 = StrOption('unicode7', "Unicode follower 7", properties=(hidden_property,), multi=True)
|
||||
descr1 = Leadership("unicode", "Common configuration 1",
|
||||
[option, option1, option2, option3, option4, option5, option6, option7])
|
||||
|
@ -1239,7 +1236,7 @@ def test_leadership_requires_complet(config_type):
|
|||
cfg.option('options.unicode.unicode').value.set(['test', 'trah'])
|
||||
cfg.option('options.unicode.unicode2', 0).value.set('test')
|
||||
dico = cfg.value.dict()
|
||||
assert dico.keys() == set(['options.unicode.unicode', 'options.unicode.unicode1', 'options.unicode.unicode2', 'options.unicode.unicode3', 'options.unicode.unicode4', 'options.unicodetoto'])
|
||||
assert dico.keys() == set(['options.unicode.unicode', 'options.unicode.unicode1', 'options.unicode.unicode2', 'options.unicode.unicode3', 'options.unicode.unicode4', 'options.unicode.unicode6', 'options.unicode.unicode7', 'options.unicodetoto'])
|
||||
assert dico['options.unicode.unicode'] == ['test', 'trah']
|
||||
assert dico['options.unicode.unicode1'] == [None, None]
|
||||
assert dico['options.unicode.unicode2'] == ['test', None]
|
||||
|
@ -1247,11 +1244,19 @@ def test_leadership_requires_complet(config_type):
|
|||
assert isinstance(dico['options.unicode.unicode3'][1], PropertiesOptionError)
|
||||
assert dico['options.unicode.unicode4'][0] is None
|
||||
assert isinstance(dico['options.unicode.unicode4'][1], PropertiesOptionError)
|
||||
assert isinstance(dico['options.unicode.unicode6'][0], PropertiesOptionError)
|
||||
assert isinstance(dico['options.unicode.unicode6'][1], PropertiesOptionError)
|
||||
assert isinstance(dico['options.unicode.unicode7'][0], PropertiesOptionError)
|
||||
assert isinstance(dico['options.unicode.unicode7'][1], PropertiesOptionError)
|
||||
assert dico['options.unicodetoto'] is None
|
||||
del dico['options.unicode.unicode3'][1]
|
||||
del dico['options.unicode.unicode3']
|
||||
del dico['options.unicode.unicode4'][1]
|
||||
del dico['options.unicode.unicode4']
|
||||
del dico['options.unicode.unicode6'][1]
|
||||
del dico['options.unicode.unicode6'][0]
|
||||
del dico['options.unicode.unicode7'][1]
|
||||
del dico['options.unicode.unicode7'][0]
|
||||
#
|
||||
cfg.option('options.unicodetoto').value.set('test')
|
||||
dico = cfg.value.dict()
|
||||
|
@ -1274,9 +1279,9 @@ def test_leadership_requires_complet(config_type):
|
|||
del dico['options.unicode.unicode4'][1]
|
||||
del dico['options.unicode.unicode4']
|
||||
del dico['options.unicode.unicode6'][1]
|
||||
del dico['options.unicode.unicode6']
|
||||
del dico['options.unicode.unicode6'][0]
|
||||
del dico['options.unicode.unicode7'][1]
|
||||
del dico['options.unicode.unicode7']
|
||||
del dico['options.unicode.unicode7'][0]
|
||||
|
||||
|
||||
def test_leadership_requires_transitive1(config_type):
|
||||
|
@ -1287,8 +1292,7 @@ def test_leadership_requires_transitive1(config_type):
|
|||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(optiontoto, raisepropertyerror=True),
|
||||
'expected': ParamValue('test'),
|
||||
'index': ParamIndex(),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option2 = StrOption('unicode2', "Unicode follower 2", properties=(disabled_property,), multi=True)
|
||||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
|
@ -1296,7 +1300,7 @@ def test_leadership_requires_transitive1(config_type):
|
|||
'expected': ParamValue('test'),
|
||||
'index': ParamIndex(),
|
||||
'no_condition_is_invalid': ParamValue(True),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option3 = StrOption('unicode3', "Unicode follower 3", properties=(disabled_property,), multi=True)
|
||||
disabled_property = Calculation(calc_value,
|
||||
Params(ParamValue('disabled'),
|
||||
|
@ -1304,7 +1308,7 @@ def test_leadership_requires_transitive1(config_type):
|
|||
'expected': ParamValue('test'),
|
||||
'index': ParamIndex(),
|
||||
'no_condition_is_invalid': ParamValue(True),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
option4 = StrOption('unicode4', "Unicode follower 4", properties=(disabled_property,), multi=True)
|
||||
descr1 = Leadership("unicode", "Common configuration 1",
|
||||
[option, option1, option2, option3, option4])
|
||||
|
|
|
@ -12,7 +12,7 @@ except:
|
|||
from tiramisu import Config
|
||||
from tiramisu.config import SubConfig
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption,\
|
||||
StrOption, SymLinkOption, UnicodeOption, IPOption, OptionDescription, \
|
||||
StrOption, SymLinkOption, StrOption, IPOption, OptionDescription, \
|
||||
PortOption, NetworkOption, NetmaskOption, DomainnameOption, EmailOption, \
|
||||
URLOption, FilenameOption
|
||||
from tiramisu.storage import list_sessions, delete_session
|
||||
|
@ -40,7 +40,7 @@ def test_slots_option():
|
|||
c = SymLinkOption('b', c)
|
||||
raises(AttributeError, "c.x = 1")
|
||||
del c
|
||||
c = UnicodeOption('a', '')
|
||||
c = StrOption('a', '')
|
||||
raises(AttributeError, "c.x = 1")
|
||||
del c
|
||||
c = IPOption('a', '')
|
||||
|
@ -78,7 +78,7 @@ def test_slots_option_readonly():
|
|||
c = IntOption('c', '')
|
||||
d = FloatOption('d', '')
|
||||
e = StrOption('e', '')
|
||||
g = UnicodeOption('g', '')
|
||||
g = StrOption('g', '')
|
||||
h = IPOption('h', '')
|
||||
i = PortOption('i', '')
|
||||
j = NetworkOption('j', '')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#from autopath import do_autopath
|
||||
#do_autopath()
|
||||
#
|
||||
from tiramisu import BoolOption, UnicodeOption, SymLinkOption, OptionDescription, DynOptionDescription, \
|
||||
from tiramisu import BoolOption, StrOption, SymLinkOption, OptionDescription, DynOptionDescription, \
|
||||
Calculation, Params, ParamOption, ParamValue, calc_value, Config
|
||||
from pickle import dumps
|
||||
from py.test import raises
|
||||
|
@ -216,8 +216,8 @@ def test_diff_opt():
|
|||
Params(ParamValue('disabled'),
|
||||
kwargs={'condition': ParamOption(b),
|
||||
'expected': ParamValue(True),
|
||||
'inverse_condition': ParamValue(True)}))
|
||||
u = UnicodeOption('u', '', properties=(disabled_property,))
|
||||
'reverse_condition': ParamValue(True)}))
|
||||
u = StrOption('u', '', properties=(disabled_property,))
|
||||
s = SymLinkOption('s', u)
|
||||
o = OptionDescription('o', '', [b, u, s])
|
||||
o1 = OptionDescription('o1', '', [o])
|
||||
|
|
|
@ -168,7 +168,7 @@ def test_callback_submulti_str():
|
|||
|
||||
|
||||
def test_callback_submulti_list():
|
||||
multi = StrOption('multi', '', [Calculation(return_list)], multi=submulti, default_multi=Calculation(return_list))
|
||||
multi = StrOption('multi', '', [Calculation(return_list)], multi=submulti, default_multi=Calculation(return_list), properties=('notunique',))
|
||||
od = OptionDescription('od', '', [multi])
|
||||
api = Config(od)
|
||||
api.property.read_write()
|
||||
|
@ -185,7 +185,7 @@ def test_callback_submulti_list():
|
|||
|
||||
|
||||
def test_callback_submulti_list_list():
|
||||
multi = StrOption('multi', '', Calculation(return_list2), multi=submulti)
|
||||
multi = StrOption('multi', '', Calculation(return_list2), multi=submulti, properties=('notunique',))
|
||||
od = OptionDescription('od', '', [multi])
|
||||
api = Config(od)
|
||||
api.property.read_write()
|
||||
|
@ -267,7 +267,7 @@ def test_reset_values_with_leader_and_followers_submulti():
|
|||
|
||||
|
||||
def test_values_with_leader_and_followers_follower_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
|
@ -286,7 +286,7 @@ def test_values_with_leader_and_followers_follower_submulti():
|
|||
|
||||
|
||||
def test_values_with_leader_and_leadership_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
|
@ -322,7 +322,7 @@ def test_values_with_leader_owner_submulti():
|
|||
|
||||
|
||||
def test_values_with_leader_disabled_submulti():
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True, properties=('notunique',))
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=submulti)
|
||||
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
maconfig = OptionDescription('toto', '', [interface1])
|
||||
|
@ -387,7 +387,7 @@ def test_callback_submulti():
|
|||
|
||||
|
||||
def test_submulti_unique():
|
||||
i = IntOption('int', '', multi=submulti, unique=True)
|
||||
i = IntOption('int', '', multi=submulti, properties=('unique',))
|
||||
o = OptionDescription('od', '', [i])
|
||||
api = Config(o)
|
||||
assert api.option('int').value.get() == []
|
||||
|
@ -399,14 +399,6 @@ def test_submulti_unique():
|
|||
api.option('int').value.set([[0, 4, 5, 6], [0]])
|
||||
|
||||
|
||||
def test_submulti_unknown_unique():
|
||||
raises(ValueError, "IntOption('int', '', multi=submulti, unique='str')")
|
||||
|
||||
|
||||
def test_unique_not_multi():
|
||||
raises(ValueError, "IntOption('int', '', unique=True)")
|
||||
|
||||
|
||||
def test_multi_submulti_meta():
|
||||
multi = StrOption('multi', '', multi=submulti)
|
||||
od = OptionDescription('od', '', [multi])
|
||||
|
|
Loading…
Reference in New Issue