In Config, name and session_id was quite equal, remove name
session_id is now validate set_value return Configs with error add new_config to MetaConfig
This commit is contained in:
@ -26,6 +26,22 @@ def return_error():
|
||||
raise Exception('test')
|
||||
|
||||
|
||||
def test_choiceoption():
|
||||
ch = ChoiceOption('ch', '', values=('val1', 'val2'))
|
||||
od = OptionDescription('od', '', [ch])
|
||||
cfg = Config(od)
|
||||
cfg.read_write()
|
||||
owner = cfg.cfgimpl_get_settings().getowner()
|
||||
assert cfg.getowner(ch) == owners.default
|
||||
cfg.ch = 'val1'
|
||||
assert cfg.getowner(ch) == owner
|
||||
del(cfg.ch)
|
||||
assert cfg.getowner(ch) == owners.default
|
||||
raises(ValueError, "cfg.ch='no'")
|
||||
assert cfg.getowner(ch) == owners.default
|
||||
assert ch.impl_get_values(cfg) == ('val1', 'val2')
|
||||
|
||||
|
||||
def test_choiceoption_function():
|
||||
ch = ChoiceOption('ch', '', values=return_list)
|
||||
od = OptionDescription('od', '', [ch])
|
||||
|
@ -52,9 +52,9 @@ def make_description():
|
||||
def test_base_config_name():
|
||||
gcdummy = BoolOption('dummy', 'dummy', default=False)
|
||||
descr = OptionDescription('tiramisu', '', [gcdummy])
|
||||
cfg = Config(descr, name='cfg')
|
||||
cfg = Config(descr, session_id='cfg')
|
||||
cfg.impl_getname() == 'cfg'
|
||||
raises(ValueError, "Config(descr, name='unvalid name')")
|
||||
raises(ValueError, "Config(descr, session_id='unvalid name')")
|
||||
|
||||
|
||||
def test_not_config():
|
||||
@ -403,6 +403,6 @@ def test_config_subconfig():
|
||||
i4 = IntOption('i4', '', default=2)
|
||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
conf1 = Config(od2, name='conf1')
|
||||
conf1 = Config(od2, session_id='conf1')
|
||||
conf1
|
||||
raises(ConfigError, "conf2 = Config(od1, name='conf2')")
|
||||
raises(ConfigError, "conf2 = Config(od1, session_id='conf2')")
|
||||
|
@ -1306,9 +1306,9 @@ def test_state_config():
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od, od1])
|
||||
try:
|
||||
cfg = Config(od2, persistent=True, session_id='29090938')
|
||||
cfg = Config(od2, persistent=True, session_id='c29090938')
|
||||
except ValueError:
|
||||
cfg = Config(od2, session_id='29090938')
|
||||
cfg = Config(od2, session_id='c29090938')
|
||||
cfg._impl_test = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
@ -1316,7 +1316,7 @@ def test_state_config():
|
||||
_diff_conf(cfg, q)
|
||||
|
||||
try:
|
||||
delete_session('config', '29090938')
|
||||
delete_session('config', 'c29090938')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
@ -6,7 +6,7 @@ from py.test import raises
|
||||
from tiramisu.setting import groups, owners
|
||||
from tiramisu.config import Config, GroupConfig, MetaConfig
|
||||
from tiramisu.option import IntOption, StrOption, NetworkOption, NetmaskOption, OptionDescription
|
||||
from tiramisu.error import ConfigError, ConflictError
|
||||
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError
|
||||
|
||||
owners.addowner('meta')
|
||||
|
||||
@ -28,9 +28,9 @@ def make_description():
|
||||
i6 = IntOption('i6', '', properties=('disabled',))
|
||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
conf1 = Config(od2, name='conf1')
|
||||
conf2 = Config(od2, name='conf2')
|
||||
meta = MetaConfig([conf1, conf2], name='meta')
|
||||
conf1 = Config(od2, session_id='conf3')
|
||||
conf2 = Config(od2, session_id='conf4')
|
||||
meta = MetaConfig([conf1, conf2], session_id='meta')
|
||||
meta.read_write()
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
return meta
|
||||
@ -184,28 +184,32 @@ def test_not_meta():
|
||||
i1 = IntOption('i1', '')
|
||||
od1 = OptionDescription('od1', '', [i1])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
conf1 = Config(od2, name='conf1')
|
||||
conf2 = Config(od2, name='conf2')
|
||||
conf1 = Config(od2, session_id='conf1')
|
||||
conf2 = Config(od2, session_id='conf2')
|
||||
conf3 = Config(od2)
|
||||
conf4 = Config(od2, name='conf2')
|
||||
conf3, conf4
|
||||
raises(ValueError, "GroupConfig(conf1)")
|
||||
#same name
|
||||
raises(ConflictError, "GroupConfig([conf2, conf4])")
|
||||
grp = GroupConfig([conf1, conf2])
|
||||
raises(ConfigError, 'grp.od1.i1')
|
||||
conf1, conf2 = grp.cfgimpl_get_children()
|
||||
grp.set_value('od1.i1', 7)
|
||||
assert grp.conf1.od1.i1 == conf2.od1.i1 == 7
|
||||
assert grp.conf1.getowner(grp.conf1.unwrap_from_path('od1.i1')) is grp.conf2.getowner(grp.conf2.unwrap_from_path('od1.i1')) is owners.user
|
||||
try:
|
||||
conf4 = Config(od2, session_id='conf2')
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
conf3, conf4
|
||||
raises(ValueError, "GroupConfig(conf1)")
|
||||
#same name
|
||||
raises(ConflictError, "GroupConfig([conf2, conf4])")
|
||||
grp = GroupConfig([conf1, conf2])
|
||||
raises(ConfigError, 'grp.od1.i1')
|
||||
conf1, conf2 = grp.cfgimpl_get_children()
|
||||
grp.set_value('od1.i1', 7)
|
||||
assert grp.conf1.od1.i1 == conf2.od1.i1 == 7
|
||||
assert grp.conf1.getowner(grp.conf1.unwrap_from_path('od1.i1')) is grp.conf2.getowner(grp.conf2.unwrap_from_path('od1.i1')) is owners.user
|
||||
|
||||
|
||||
def test_group_find_firsts():
|
||||
i1 = IntOption('i1', '')
|
||||
od1 = OptionDescription('od1', '', [i1])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
conf1 = Config(od2, name='conf1')
|
||||
conf2 = Config(od2, name='conf2')
|
||||
conf1 = Config(od2, session_id='conf1')
|
||||
conf2 = Config(od2, session_id='conf2')
|
||||
grp = GroupConfig([conf1, conf2])
|
||||
assert [conf1, conf2] == grp.find_firsts(byname='i1').cfgimpl_get_children()
|
||||
|
||||
@ -214,15 +218,13 @@ def test_group_group():
|
||||
i1 = IntOption('i1', '')
|
||||
od1 = OptionDescription('od1', '', [i1])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
conf1 = Config(od2, name='conf1')
|
||||
conf2 = Config(od2, name='conf2')
|
||||
grp = GroupConfig([conf1, conf2])
|
||||
raises(ValueError, "GroupConfig([grp])")
|
||||
conf1 = Config(od2, session_id='conf9')
|
||||
conf2 = Config(od2, session_id='conf10')
|
||||
grp = GroupConfig([conf1, conf2], 'grp')
|
||||
grp2 = GroupConfig([grp])
|
||||
grp2.set_value('od1.i1', 2)
|
||||
assert grp2.grp.conf1.od1.i1 == 2
|
||||
assert grp2.grp.conf1.getowner(i1) == owners.user
|
||||
assert grp2.grp.conf9.od1.i1 == 2
|
||||
assert grp2.grp.conf9.getowner(i1) == owners.user
|
||||
|
||||
|
||||
def test_meta_path():
|
||||
@ -239,10 +241,10 @@ def test_meta_unconsistent():
|
||||
od1 = OptionDescription('od1', '', [i1, i2, i3, i4])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
od3 = OptionDescription('od3', '', [od1])
|
||||
conf1 = Config(od2, name='conf1')
|
||||
conf2 = Config(od2, name='conf2')
|
||||
conf3 = Config(od2, name='conf3')
|
||||
conf4 = Config(od3, name='conf4')
|
||||
conf1 = Config(od2, session_id='conf5')
|
||||
conf2 = Config(od2, session_id='conf6')
|
||||
conf3 = Config(od2, session_id='conf7')
|
||||
conf4 = Config(od3, session_id='conf8')
|
||||
conf3, conf4
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
@ -251,7 +253,7 @@ def test_meta_unconsistent():
|
||||
raises(ValueError, "MetaConfig([conf1, conf3])")
|
||||
#not same descr
|
||||
raises(ValueError, "MetaConfig([conf3, conf4])")
|
||||
raises(ConfigError, "meta.conf1.read_only()")
|
||||
raises(ConfigError, "meta.conf5.read_only()")
|
||||
|
||||
|
||||
def test_meta_master_slaves():
|
||||
@ -259,8 +261,8 @@ def test_meta_master_slaves():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_only()
|
||||
assert [conf1, conf2] == meta.find_firsts(byname='netmask_admin_eth0').cfgimpl_get_children()
|
||||
@ -277,8 +279,8 @@ def test_meta_master_slaves_value():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.conf1.ip_admin_eth0 = ['192.168.1.1']
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
@ -299,8 +301,8 @@ def test_meta_master_slaves_value_default():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
assert meta.conf1.netmask_admin_eth0 == [None]
|
||||
meta.ip_admin_eth0 = ['192.168.1.1']
|
||||
@ -318,8 +320,8 @@ def test_meta_master_slaves_owners():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.cfgimpl_get_settings().setowner(owners.meta)
|
||||
assert meta.conf1.getowner(ip_admin_eth0) == owners.default
|
||||
@ -349,9 +351,9 @@ def test_meta_force_default():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -382,9 +384,9 @@ def test_meta_force_dont_change_value():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -410,9 +412,9 @@ def test_meta_force_default_if_same():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -452,9 +454,9 @@ def test_meta_force_default_if_same_and_dont_change():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -494,9 +496,9 @@ def test_meta_force_default_and_dont_change():
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -510,9 +512,9 @@ def test_meta_properties_meta():
|
||||
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -525,9 +527,9 @@ def test_meta_exception_meta():
|
||||
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
conf1 = Config(interface1, name='conf1')
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(interface1, name='conf2')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
@ -541,7 +543,7 @@ def test_meta_callback():
|
||||
val4 = StrOption('val4', "", callback=return_value, callback_params={'value': ((val1, False),)})
|
||||
val5 = StrOption('val5', "", callback=return_value, callback_params={'value': ('yes',)})
|
||||
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
||||
cfg = Config(maconfig, name='cfg')
|
||||
cfg = Config(maconfig, session_id='cfg')
|
||||
meta = MetaConfig([cfg])
|
||||
meta.read_write()
|
||||
assert meta.cfg.make_dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
||||
@ -567,7 +569,7 @@ def test_meta_callback_slave():
|
||||
interface1 = OptionDescription('val1', '', [val1, val3, val4])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
||||
cfg = Config(maconfig, name='cfg')
|
||||
cfg = Config(maconfig, session_id='cfg')
|
||||
meta = MetaConfig([cfg])
|
||||
meta.read_write()
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
||||
@ -599,3 +601,42 @@ def test_meta_callback_slave():
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||
meta.val1.val1 = ['val4']
|
||||
assert meta.cfg.make_dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
||||
|
||||
|
||||
def test_meta_properties_meta_set_value():
|
||||
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
||||
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask", multi=True, properties=('disabled',))
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
conf1 = Config(interface1, session_id='conf1')
|
||||
conf2 = Config(interface1, session_id='conf2')
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
assert conf1.make_dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
||||
ret = meta.set_value('netmask_admin_eth0', ['255.255.255.255'], only_config=True)
|
||||
assert len(ret) == 2
|
||||
assert isinstance(ret[0], PropertiesOptionError)
|
||||
assert isinstance(ret[1], PropertiesOptionError)
|
||||
ret = meta.set_value('netmask_admin_eth0', ['255.255.255.255'], force_default=True)
|
||||
assert len(ret) == 1
|
||||
assert isinstance(ret[0], PropertiesOptionError)
|
||||
ret = meta.set_value('netmask_admin_eth0', ['255.255.255.255'], force_dont_change_value=True)
|
||||
assert len(ret) == 3
|
||||
assert isinstance(ret[0], PropertiesOptionError)
|
||||
assert isinstance(ret[1], PropertiesOptionError)
|
||||
assert isinstance(ret[2], PropertiesOptionError)
|
||||
ret = meta.set_value('netmask_admin_eth0', ['255.255.255.255'], force_default_if_same=True)
|
||||
assert len(ret) == 1
|
||||
assert isinstance(ret[0], PropertiesOptionError)
|
||||
ret = meta.set_value('ip_admin_eth0', '255.255.255.255', only_config=True)
|
||||
assert len(ret) == 2
|
||||
assert isinstance(ret[0], ValueError)
|
||||
assert isinstance(ret[1], ValueError)
|
||||
ret = meta.set_value('ip_admin_eth0', '255.255.255.255', force_default=True)
|
||||
assert len(ret) == 1
|
||||
assert isinstance(ret[0], ValueError)
|
||||
ret = meta.set_value('ip_admin_eth0', '255.255.255.255', force_dont_change_value=True)
|
||||
assert len(ret) == 1
|
||||
assert isinstance(ret[0], ValueError)
|
||||
ret = meta.set_value('ip_admin_eth0', '255.255.255.255', force_default_if_same=True)
|
||||
assert len(ret) == 1
|
||||
assert isinstance(ret[0], ValueError)
|
||||
|
@ -207,6 +207,9 @@ def _diff_conf(cfg1, cfg2):
|
||||
elif attr == '_impl_children':
|
||||
for index, _opt in enumerate(val1):
|
||||
_diff_conf(_opt, val2[index])
|
||||
elif attr == '_impl_name':
|
||||
#FIXME
|
||||
pass
|
||||
else:
|
||||
assert val1 == val2
|
||||
|
||||
@ -256,9 +259,9 @@ def test_diff_information_config():
|
||||
o = OptionDescription('o', '', [b])
|
||||
o1 = OptionDescription('o1', '', [o])
|
||||
try:
|
||||
cfg = Config(o1, persistent=True, session_id='29090938')
|
||||
cfg = Config(o1, persistent=True, session_id='c29090938')
|
||||
except ValueError:
|
||||
cfg = Config(o1, session_id='29090938')
|
||||
cfg = Config(o1, session_id='c29090938')
|
||||
cfg._impl_test = True
|
||||
cfg.impl_set_information('info', 'oh')
|
||||
|
||||
@ -269,7 +272,7 @@ def test_diff_information_config():
|
||||
assert cfg.impl_get_information('info') == 'oh'
|
||||
assert q.impl_get_information('info') == 'oh'
|
||||
try:
|
||||
delete_session('config', '29090938')
|
||||
delete_session('config', 'c29090938')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -341,16 +344,16 @@ def test_state_config():
|
||||
val1 = BoolOption('val1', "")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
try:
|
||||
cfg = Config(maconfig, persistent=True, session_id='29090931')
|
||||
cfg = Config(maconfig, persistent=True, session_id='c29090931')
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090931')
|
||||
cfg = Config(maconfig, session_id='c29090931')
|
||||
cfg._impl_test = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
try:
|
||||
delete_session('config', '29090931')
|
||||
delete_session('config', 'c29090931')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -370,16 +373,16 @@ def test_state_config2():
|
||||
od = OptionDescription('od', '', [st])
|
||||
od2 = OptionDescription('od', '', [od, od1])
|
||||
try:
|
||||
cfg = Config(od2, persistent=True, session_id='29090939')
|
||||
cfg = Config(od2, persistent=True, session_id='c29090939')
|
||||
except ValueError:
|
||||
cfg = Config(od2, session_id='29090939')
|
||||
cfg = Config(od2, session_id='c29090939')
|
||||
cfg._impl_test = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
try:
|
||||
delete_session('config', '29090939')
|
||||
delete_session('config', 'c29090939')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -391,9 +394,9 @@ def test_diff_opt_value():
|
||||
o = OptionDescription('o', '', [b, u, s])
|
||||
o1 = OptionDescription('o1', '', [o])
|
||||
try:
|
||||
cfg = Config(o1, persistent=True, session_id='29090941')
|
||||
cfg = Config(o1, persistent=True, session_id='c29090941')
|
||||
except ValueError:
|
||||
cfg = Config(o1, session_id='29090941')
|
||||
cfg = Config(o1, session_id='c29090941')
|
||||
cfg._impl_test = True
|
||||
|
||||
a = dumps(cfg)
|
||||
@ -401,7 +404,7 @@ def test_diff_opt_value():
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
try:
|
||||
delete_session('config', '29090941')
|
||||
delete_session('config', 'c29090941')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -416,9 +419,9 @@ def test_diff_opt_config():
|
||||
o = OptionDescription('o', '', [b, u, s])
|
||||
o1 = OptionDescription('o1', '', [o])
|
||||
try:
|
||||
cfg = Config(o1, persistent=True, session_id='29090940')
|
||||
cfg = Config(o1, persistent=True, session_id='c29090940')
|
||||
except ValueError:
|
||||
cfg = Config(o1, session_id='29090940')
|
||||
cfg = Config(o1, session_id='c29090940')
|
||||
cfg._impl_test = True
|
||||
|
||||
a = dumps(cfg)
|
||||
@ -426,7 +429,7 @@ def test_diff_opt_config():
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
try:
|
||||
delete_session('config', '29090940')
|
||||
delete_session('config', 'c29090940')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -435,9 +438,9 @@ def test_state_properties():
|
||||
val1 = BoolOption('val1', "")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
try:
|
||||
cfg = Config(maconfig, persistent=True, session_id='29090932')
|
||||
cfg = Config(maconfig, persistent=True, session_id='c29090932')
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090932')
|
||||
cfg = Config(maconfig, session_id='c29090932')
|
||||
cfg._impl_test = True
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_settings()[val1].append('test')
|
||||
@ -445,7 +448,7 @@ def test_state_properties():
|
||||
q = loads(a)
|
||||
_diff_conf(cfg, q)
|
||||
try:
|
||||
delete_session('config', '29090932')
|
||||
delete_session('config', 'c29090932')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -454,9 +457,9 @@ def test_state_values():
|
||||
val1 = BoolOption('val1', "")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
try:
|
||||
cfg = Config(maconfig, persistent=True, session_id='29090933')
|
||||
cfg = Config(maconfig, persistent=True, session_id='c29090933')
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090933')
|
||||
cfg = Config(maconfig, session_id='c29090933')
|
||||
cfg._impl_test = True
|
||||
cfg.val1 = True
|
||||
a = dumps(cfg)
|
||||
@ -466,7 +469,7 @@ def test_state_values():
|
||||
assert cfg.val1 is True
|
||||
assert q.val1 is False
|
||||
try:
|
||||
delete_session('config', '29090933')
|
||||
delete_session('config', 'c29090933')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -475,9 +478,9 @@ def test_state_values_owner():
|
||||
val1 = BoolOption('val1', "")
|
||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
||||
try:
|
||||
cfg = Config(maconfig, persistent=True, session_id='29090934')
|
||||
cfg = Config(maconfig, persistent=True, session_id='c29090934')
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090934')
|
||||
cfg = Config(maconfig, session_id='c29090934')
|
||||
cfg._impl_test = True
|
||||
owners.addowner('newowner')
|
||||
cfg.cfgimpl_get_settings().setowner(owners.newowner)
|
||||
@ -489,7 +492,7 @@ def test_state_values_owner():
|
||||
nval1 = q.cfgimpl_get_description().val1
|
||||
assert q.getowner(nval1) == owners.newowner
|
||||
try:
|
||||
delete_session('config', '29090934')
|
||||
delete_session('config', 'c29090934')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -499,17 +502,17 @@ def test_state_metaconfig():
|
||||
od1 = OptionDescription('od1', '', [i1])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
try:
|
||||
cfg = Config(od2, persistent=True, session_id='29090935')
|
||||
cfg = Config(od2, persistent=True, session_id='c29090935')
|
||||
except ValueError:
|
||||
conf1 = Config(od2, session_id='29090935')
|
||||
conf1 = Config(od2, session_id='c29090935')
|
||||
conf1._impl_test = True
|
||||
conf2 = Config(od2, session_id='29090936')
|
||||
conf2 = Config(od2, session_id='c29090936')
|
||||
conf2._impl_test = True
|
||||
meta = MetaConfig([conf1, conf2], session_id='29090937')
|
||||
meta = MetaConfig([conf1, conf2], session_id='c29090937')
|
||||
meta._impl_test = True
|
||||
raises(ConfigError, "dumps(meta)")
|
||||
try:
|
||||
delete_session('config', '29090935')
|
||||
delete_session('config', 'c29090935')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -519,19 +522,19 @@ def test_state_groupconfig():
|
||||
od1 = OptionDescription('od1', '', [i1])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
try:
|
||||
cfg = Config(od2, persistent=True, session_id='29090938')
|
||||
cfg = Config(od2, persistent=True, session_id='c29090938')
|
||||
except ValueError:
|
||||
conf1 = Config(od2, session_id='29090938')
|
||||
conf1 = Config(od2, session_id='c29090938')
|
||||
conf1._impl_test = True
|
||||
conf2 = Config(od2, session_id='29090939')
|
||||
conf2 = Config(od2, session_id='c29090939')
|
||||
conf2._impl_test = True
|
||||
meta = GroupConfig([conf1, conf2], session_id='29090940')
|
||||
meta = GroupConfig([conf1, conf2], session_id='c29090940')
|
||||
meta._impl_test = True
|
||||
a = dumps(meta)
|
||||
q = loads(a)
|
||||
_diff_conf(meta, q)
|
||||
try:
|
||||
delete_session('config', '29090938')
|
||||
delete_session('config', 'c29090938')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
@ -684,9 +684,9 @@ def test_submulti_unique():
|
||||
def test_multi_submulti_meta():
|
||||
multi = StrOption('multi', '', multi=submulti)
|
||||
od = OptionDescription('od', '', [multi])
|
||||
conf1 = Config(od, name='conf1')
|
||||
conf1 = Config(od, session_id='conf1')
|
||||
conf1.read_write()
|
||||
conf2 = Config(od, name='conf2')
|
||||
conf2 = Config(od, session_id='conf2')
|
||||
conf2.read_write()
|
||||
meta = MetaConfig([conf1, conf2])
|
||||
meta.read_write()
|
||||
|
Reference in New Issue
Block a user