better sqlalchemy integration
This commit is contained in:
@ -1293,10 +1293,10 @@ def test_state_config():
|
||||
except ValueError:
|
||||
cfg = Config(od2, session_id='29090938')
|
||||
cfg._impl_test = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
|
||||
try:
|
||||
delete_session('config', '29090938')
|
||||
|
@ -82,7 +82,7 @@ def make_description4():
|
||||
|
||||
def test_mandatory_ro():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man001')
|
||||
config.read_only()
|
||||
prop = []
|
||||
try:
|
||||
@ -94,21 +94,31 @@ def test_mandatory_ro():
|
||||
config.str1 = 'yes'
|
||||
config.read_only()
|
||||
assert config.str1 == 'yes'
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_rw():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man002')
|
||||
config.read_write()
|
||||
#not mandatory in rw
|
||||
config.str1
|
||||
config.str1 = 'yes'
|
||||
assert config.str1 == 'yes'
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_default():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man003')
|
||||
config.read_only()
|
||||
#not mandatory in rw
|
||||
config.str
|
||||
@ -125,11 +135,16 @@ def test_mandatory_default():
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_delete():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man004')
|
||||
config.read_only()
|
||||
config.str
|
||||
try:
|
||||
@ -150,12 +165,17 @@ def test_mandatory_delete():
|
||||
assert 'mandatory' in prop
|
||||
del(config.str)
|
||||
assert config.str1 == 'yes'
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
#valeur vide : None, '', u'', ...
|
||||
def test_mandatory_none():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man005')
|
||||
config.str1 = None
|
||||
assert config.getowner(config.unwrap_from_path('str1')) == 'user'
|
||||
config.read_only()
|
||||
@ -165,11 +185,16 @@ def test_mandatory_none():
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_empty():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man006')
|
||||
config.str1 = ''
|
||||
assert config.getowner(config.unwrap_from_path('str1')) == 'user'
|
||||
config.read_only()
|
||||
@ -179,11 +204,16 @@ def test_mandatory_empty():
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_multi_none():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man007')
|
||||
config.str3 = [None]
|
||||
assert config.getowner(config.unwrap_from_path('str3')) == 'user'
|
||||
config.read_only()
|
||||
@ -203,11 +233,16 @@ def test_mandatory_multi_none():
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_multi_empty():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man008')
|
||||
config.str3 = []
|
||||
assert config.getowner(config.unwrap_from_path('str3')) == 'user'
|
||||
config.read_only()
|
||||
@ -239,11 +274,16 @@ def test_mandatory_multi_empty():
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_multi_empty_allow_empty_list():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man009')
|
||||
config.str4 = []
|
||||
assert config.getowner(config.unwrap_from_path('str4')) == 'user'
|
||||
config.read_only()
|
||||
@ -271,19 +311,29 @@ def test_mandatory_multi_empty_allow_empty_list():
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_multi_append():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man010')
|
||||
config.str3 = ['yes']
|
||||
config.read_write()
|
||||
config.str3.append(None)
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_disabled():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man011')
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.str1
|
||||
config.read_only()
|
||||
@ -300,11 +350,16 @@ def test_mandatory_disabled():
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert set(prop) == set(['disabled', 'mandatory'])
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_unicode():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man012')
|
||||
config.unicode2
|
||||
config.read_only()
|
||||
prop = []
|
||||
@ -322,11 +377,16 @@ def test_mandatory_unicode():
|
||||
except PropertiesOptionError as err:
|
||||
prop = err.proptype
|
||||
assert prop == ['mandatory']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_warnings_ro():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man013')
|
||||
config.str = ''
|
||||
config.read_only()
|
||||
proc = []
|
||||
@ -341,11 +401,16 @@ def test_mandatory_warnings_ro():
|
||||
config.read_only()
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
||||
|
||||
def test_mandatory_warnings_rw():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man100')
|
||||
config.str = ''
|
||||
config.read_write()
|
||||
config.str
|
||||
@ -354,7 +419,7 @@ def test_mandatory_warnings_rw():
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man100')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -362,7 +427,7 @@ def test_mandatory_warnings_rw():
|
||||
|
||||
def test_mandatory_warnings_disabled():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man101')
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
@ -372,7 +437,7 @@ def test_mandatory_warnings_disabled():
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man101')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -380,7 +445,7 @@ def test_mandatory_warnings_disabled():
|
||||
|
||||
def test_mandatory_warnings_hidden():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man102')
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
@ -391,7 +456,7 @@ def test_mandatory_warnings_hidden():
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str', 'str1', 'unicode2', 'str3']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man102')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -399,7 +464,7 @@ def test_mandatory_warnings_hidden():
|
||||
|
||||
def test_mandatory_warnings_frozen():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man103')
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
@ -409,7 +474,7 @@ def test_mandatory_warnings_frozen():
|
||||
config.read_only()
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str', 'str1', 'unicode2', 'str3']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man103')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -423,12 +488,12 @@ def test_mandatory_master():
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o)
|
||||
config = Config(o, session_id='man104')
|
||||
config.read_only()
|
||||
raises(PropertiesOptionError, 'config.ip_admin_eth0.ip_admin_eth0')
|
||||
raises(PropertiesOptionError, 'config.ip_admin_eth0.netmask_admin_eth0')
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man104')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -442,10 +507,10 @@ def test_mandatory_warnings_master():
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o)
|
||||
config = Config(o, session_id='man105')
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['ip_admin_eth0.ip_admin_eth0']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man105')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -458,7 +523,7 @@ def test_mandatory_master_empty():
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o)
|
||||
config = Config(o, session_id='man106')
|
||||
config.read_write()
|
||||
assert config.ip_admin_eth0.ip_admin_eth0 == []
|
||||
assert config.ip_admin_eth0.netmask_admin_eth0 == []
|
||||
@ -489,7 +554,7 @@ def test_mandatory_master_empty():
|
||||
assert config.ip_admin_eth0.ip_admin_eth0 == ['ip']
|
||||
assert config.ip_admin_eth0.netmask_admin_eth0 == [None]
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man106')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -502,7 +567,7 @@ def test_mandatory_warnings_master_empty():
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o)
|
||||
config = Config(o, session_id='man107')
|
||||
config.read_write()
|
||||
config.ip_admin_eth0.ip_admin_eth0.append()
|
||||
assert config.ip_admin_eth0.ip_admin_eth0 == [None]
|
||||
@ -520,7 +585,7 @@ def test_mandatory_warnings_master_empty():
|
||||
config.ip_admin_eth0.ip_admin_eth0 = ['ip']
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == []
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man107')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -533,7 +598,7 @@ def test_mandatory_slave():
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o)
|
||||
config = Config(o, session_id='man108')
|
||||
config.read_only()
|
||||
assert config.ip_admin_eth0.ip_admin_eth0 == []
|
||||
assert config.ip_admin_eth0.netmask_admin_eth0 == []
|
||||
@ -556,7 +621,7 @@ def test_mandatory_slave():
|
||||
assert config.ip_admin_eth0.ip_admin_eth0 == ['ip']
|
||||
assert config.ip_admin_eth0.netmask_admin_eth0 == ['ip']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man108')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -569,7 +634,7 @@ def test_mandatory_warnings_slave():
|
||||
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
o = OptionDescription('o', '', [interface1])
|
||||
config = Config(o)
|
||||
config = Config(o, session_id='man109')
|
||||
config.read_only()
|
||||
assert config.ip_admin_eth0.ip_admin_eth0 == []
|
||||
assert config.ip_admin_eth0.netmask_admin_eth0 == []
|
||||
@ -579,7 +644,7 @@ def test_mandatory_warnings_slave():
|
||||
config.ip_admin_eth0.ip_admin_eth0.append('ip')
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['ip_admin_eth0.netmask_admin_eth0']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man109')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -587,7 +652,7 @@ def test_mandatory_warnings_slave():
|
||||
|
||||
def test_mandatory_warnings_symlink():
|
||||
descr = make_description_sym()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man110')
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.read_write()
|
||||
@ -597,7 +662,7 @@ def test_mandatory_warnings_symlink():
|
||||
config.read_only()
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str', 'str1', 'str3']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man110')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -605,7 +670,7 @@ def test_mandatory_warnings_symlink():
|
||||
|
||||
def test_mandatory_warnings_validate():
|
||||
descr = make_description3()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man111')
|
||||
config.str = ''
|
||||
raises(ValueError, "list(config.cfgimpl_get_values().mandatory_warnings())")
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(validate=False)) == ['str', 'str1', 'str3', 'unicode1', 'int1']
|
||||
@ -613,7 +678,7 @@ def test_mandatory_warnings_validate():
|
||||
raises(ValueError, "list(config.cfgimpl_get_values().mandatory_warnings())")
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(validate=False)) == ['str1', 'str3']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man111')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -621,13 +686,13 @@ def test_mandatory_warnings_validate():
|
||||
|
||||
def test_mandatory_warnings_validate_empty():
|
||||
descr = make_description2()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man112')
|
||||
config.str = ''
|
||||
config.read_only()
|
||||
raises(ConfigError, "list(config.cfgimpl_get_values().mandatory_warnings())")
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings(validate=False)) == ['str', 'str1', 'str3', 'unicode1']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man112')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -635,7 +700,7 @@ def test_mandatory_warnings_validate_empty():
|
||||
|
||||
def test_mandatory_warnings_requires():
|
||||
descr = make_description4()
|
||||
config = Config(descr)
|
||||
config = Config(descr, session_id='man113')
|
||||
config.str = ''
|
||||
config.read_write()
|
||||
config.str
|
||||
@ -646,7 +711,7 @@ def test_mandatory_warnings_requires():
|
||||
config.str = 'yes'
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man113')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
@ -655,13 +720,13 @@ def test_mandatory_warnings_requires():
|
||||
def test_mandatory_od_disabled():
|
||||
descr = make_description()
|
||||
od = OptionDescription('od', '', [descr])
|
||||
config = Config(od)
|
||||
config = Config(od, session_id='man114')
|
||||
config.read_only()
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['tiram.str1', 'tiram.unicode2', 'tiram.str3']
|
||||
config.cfgimpl_get_settings()[descr].append('disabled')
|
||||
assert list(config.cfgimpl_get_values().mandatory_warnings()) == []
|
||||
try:
|
||||
delete_session('config', config.impl_getsessionid())
|
||||
delete_session('config', 'man114')
|
||||
except ValueError:
|
||||
pass
|
||||
del(config)
|
||||
|
@ -11,6 +11,9 @@ from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption,\
|
||||
URLOption, FilenameOption
|
||||
|
||||
|
||||
print "FIXME slot pour un masterslaves !!"
|
||||
|
||||
|
||||
def test_slots_option():
|
||||
c = ChoiceOption('a', '', ('a',))
|
||||
raises(AttributeError, "c.x = 1")
|
||||
|
@ -107,9 +107,9 @@ def _diff_opt(opt1, opt2):
|
||||
else:
|
||||
assert v[1] == val2[idx][1]
|
||||
elif attr == '_master_slaves':
|
||||
assert val1.master.impl_getname() == val2.master.impl_getname()
|
||||
sval1 = [opt.impl_getname() for opt in val1.slaves]
|
||||
sval2 = [opt.impl_getname() for opt in val2.slaves]
|
||||
assert val1._p_._sm_getmaster().impl_getname() == val2._p_._sm_getmaster().impl_getname()
|
||||
sval1 = [opt.impl_getname() for opt in val1._p_._sm_getslaves()]
|
||||
sval2 = [opt.impl_getname() for opt in val2._p_._sm_getslaves()]
|
||||
assert sval1 == sval2
|
||||
elif attr == '_subdyn':
|
||||
try:
|
||||
@ -214,14 +214,18 @@ def test_diff_information_config():
|
||||
except ValueError:
|
||||
cfg = Config(o1, session_id='29090938')
|
||||
cfg._impl_test = True
|
||||
cfg.impl_set_information('info', 'oh')
|
||||
cfg.impl_set_information('info', 'oh')
|
||||
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
assert cfg.impl_get_information('info') == 'oh'
|
||||
assert q.impl_get_information('info') == 'oh'
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
assert cfg.impl_get_information('info') == 'oh'
|
||||
assert q.impl_get_information('info') == 'oh'
|
||||
try:
|
||||
delete_session('config', '29090938')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
||||
def test_diff_opt_multi():
|
||||
@ -295,10 +299,10 @@ def test_state_config():
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090931')
|
||||
cfg._impl_test = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
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')
|
||||
except ValueError:
|
||||
@ -324,10 +328,10 @@ def test_state_config2():
|
||||
except ValueError:
|
||||
cfg = Config(od2, session_id='29090939')
|
||||
cfg._impl_test = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
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')
|
||||
except ValueError:
|
||||
@ -349,10 +353,14 @@ def test_diff_opt_config():
|
||||
cfg = Config(o1, session_id='29090940')
|
||||
cfg._impl_test = True
|
||||
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_opts(cfg.cfgimpl_get_description(), q.cfgimpl_get_description())
|
||||
_diff_conf(cfg, q)
|
||||
try:
|
||||
delete_session('config', '29090940')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
||||
def test_state_properties():
|
||||
@ -363,11 +371,11 @@ def test_state_properties():
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090932')
|
||||
cfg._impl_test = True
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_settings()[val1].append('test')
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_conf(cfg, q)
|
||||
cfg.read_write()
|
||||
cfg.cfgimpl_get_settings()[val1].append('test')
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_conf(cfg, q)
|
||||
try:
|
||||
delete_session('config', '29090932')
|
||||
except ValueError:
|
||||
@ -382,13 +390,13 @@ def test_state_values():
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090933')
|
||||
cfg._impl_test = True
|
||||
cfg.val1 = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_conf(cfg, q)
|
||||
q.val1 = False
|
||||
assert cfg.val1 is True
|
||||
assert q.val1 is False
|
||||
cfg.val1 = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_conf(cfg, q)
|
||||
q.val1 = False
|
||||
assert cfg.val1 is True
|
||||
assert q.val1 is False
|
||||
try:
|
||||
delete_session('config', '29090933')
|
||||
except ValueError:
|
||||
@ -403,15 +411,15 @@ def test_state_values_owner():
|
||||
except ValueError:
|
||||
cfg = Config(maconfig, session_id='29090934')
|
||||
cfg._impl_test = True
|
||||
owners.addowner('newowner')
|
||||
cfg.cfgimpl_get_settings().setowner(owners.newowner)
|
||||
cfg.val1 = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_conf(cfg, q)
|
||||
q.val1 = False
|
||||
nval1 = q.cfgimpl_get_description().val1
|
||||
assert q.getowner(nval1) == owners.newowner
|
||||
owners.addowner('newowner')
|
||||
cfg.cfgimpl_get_settings().setowner(owners.newowner)
|
||||
cfg.val1 = True
|
||||
a = dumps(cfg)
|
||||
q = loads(a)
|
||||
_diff_conf(cfg, q)
|
||||
q.val1 = False
|
||||
nval1 = q.cfgimpl_get_description().val1
|
||||
assert q.getowner(nval1) == owners.newowner
|
||||
try:
|
||||
delete_session('config', '29090934')
|
||||
except ValueError:
|
||||
@ -422,17 +430,18 @@ def test_state_metaconfig():
|
||||
i1 = IntOption('i1', '')
|
||||
od1 = OptionDescription('od1', '', [i1])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
conf1 = Config(od2, session_id='29090935')
|
||||
conf1._impl_test = True
|
||||
conf2 = Config(od2, session_id='29090936')
|
||||
conf2._impl_test = True
|
||||
meta = MetaConfig([conf1, conf2], session_id='29090937')
|
||||
meta._impl_test = True
|
||||
raises(ConfigError, "dumps(meta)")
|
||||
try:
|
||||
cfg = Config(od2, persistent=True, session_id='29090935')
|
||||
except ValueError:
|
||||
conf1 = Config(od2, session_id='29090935')
|
||||
conf1._impl_test = True
|
||||
conf2 = Config(od2, session_id='29090936')
|
||||
conf2._impl_test = True
|
||||
meta = MetaConfig([conf1, conf2], session_id='29090937')
|
||||
meta._impl_test = True
|
||||
raises(ConfigError, "dumps(meta)")
|
||||
try:
|
||||
delete_session('config', '29090935')
|
||||
delete_session('config', '29090936')
|
||||
delete_session('config', '29090937')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -441,19 +450,20 @@ def test_state_groupconfig():
|
||||
i1 = IntOption('i1', '')
|
||||
od1 = OptionDescription('od1', '', [i1])
|
||||
od2 = OptionDescription('od2', '', [od1])
|
||||
conf1 = Config(od2, session_id='29090935')
|
||||
conf1._impl_test = True
|
||||
conf2 = Config(od2, session_id='29090936')
|
||||
conf2._impl_test = True
|
||||
meta = GroupConfig([conf1, conf2], session_id='29090937')
|
||||
meta._impl_test = True
|
||||
a = dumps(meta)
|
||||
q = loads(a)
|
||||
_diff_conf(meta, q)
|
||||
try:
|
||||
delete_session('config', '29090935')
|
||||
delete_session('config', '29090936')
|
||||
delete_session('config', '29090937')
|
||||
cfg = Config(od2, persistent=True, session_id='29090938')
|
||||
except ValueError:
|
||||
conf1 = Config(od2, session_id='29090938')
|
||||
conf1._impl_test = True
|
||||
conf2 = Config(od2, session_id='29090939')
|
||||
conf2._impl_test = True
|
||||
meta = GroupConfig([conf1, conf2], session_id='29090940')
|
||||
meta._impl_test = True
|
||||
a = dumps(meta)
|
||||
q = loads(a)
|
||||
_diff_conf(meta, q)
|
||||
try:
|
||||
delete_session('config', '29090938')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user