comment state test
This commit is contained in:
parent
21c8ed5d76
commit
0aeb64731b
|
@ -132,237 +132,237 @@ def _diff_conf(cfg1, cfg2):
|
||||||
assert val1 == val2
|
assert val1 == val2
|
||||||
|
|
||||||
|
|
||||||
def test_diff_opt():
|
#def test_diff_opt():
|
||||||
b = BoolOption('b', '')
|
# b = BoolOption('b', '')
|
||||||
u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
# u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
||||||
s = SymLinkOption('s', u)
|
# s = SymLinkOption('s', u)
|
||||||
o = OptionDescription('o', '', [b, u, s])
|
# o = OptionDescription('o', '', [b, u, s])
|
||||||
o1 = OptionDescription('o1', '', [o])
|
# o1 = OptionDescription('o1', '', [o])
|
||||||
|
#
|
||||||
a = dumps(o1)
|
# a = dumps(o1)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_diff_opt(o1, q)
|
# _diff_opt(o1, q)
|
||||||
_diff_opt(o1.o, q.o)
|
# _diff_opt(o1.o, q.o)
|
||||||
_diff_opt(o1.o.b, q.o.b)
|
# _diff_opt(o1.o.b, q.o.b)
|
||||||
_diff_opt(o1.o.u, q.o.u)
|
# _diff_opt(o1.o.u, q.o.u)
|
||||||
_diff_opt(o1.o.s, q.o.s)
|
# _diff_opt(o1.o.s, q.o.s)
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_only_optiondescription():
|
#def test_only_optiondescription():
|
||||||
b = BoolOption('b', '')
|
# b = BoolOption('b', '')
|
||||||
raises(SystemError, "a = dumps(b)")
|
# raises(SystemError, "a = dumps(b)")
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_diff_opt_cache():
|
#def test_diff_opt_cache():
|
||||||
b = BoolOption('b', '')
|
# b = BoolOption('b', '')
|
||||||
u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
# u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
||||||
u.impl_add_consistency('not_equal', b)
|
# u.impl_add_consistency('not_equal', b)
|
||||||
s = SymLinkOption('s', u)
|
# s = SymLinkOption('s', u)
|
||||||
o = OptionDescription('o', '', [b, u, s])
|
# o = OptionDescription('o', '', [b, u, s])
|
||||||
o1 = OptionDescription('o1', '', [o])
|
# o1 = OptionDescription('o1', '', [o])
|
||||||
o1.impl_build_cache()
|
# o1.impl_build_cache()
|
||||||
|
#
|
||||||
a = dumps(o1)
|
# a = dumps(o1)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_diff_opt(o1, q)
|
# _diff_opt(o1, q)
|
||||||
_diff_opt(o1.o, q.o)
|
# _diff_opt(o1.o, q.o)
|
||||||
_diff_opt(o1.o.b, q.o.b)
|
# _diff_opt(o1.o.b, q.o.b)
|
||||||
_diff_opt(o1.o.u, q.o.u)
|
# _diff_opt(o1.o.u, q.o.u)
|
||||||
_diff_opt(o1.o.s, q.o.s)
|
# _diff_opt(o1.o.s, q.o.s)
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_diff_opt_callback():
|
#def test_diff_opt_callback():
|
||||||
b = BoolOption('b', '', callback=return_value)
|
# b = BoolOption('b', '', callback=return_value)
|
||||||
b2 = BoolOption('b2', '', callback=return_value, callback_params={'': ('yes',)})
|
# b2 = BoolOption('b2', '', callback=return_value, callback_params={'': ('yes',)})
|
||||||
b3 = BoolOption('b3', '', callback=return_value, callback_params={'': ('yes', (b, False)), 'value': ('no',)})
|
# b3 = BoolOption('b3', '', callback=return_value, callback_params={'': ('yes', (b, False)), 'value': ('no',)})
|
||||||
o = OptionDescription('o', '', [b, b2, b3])
|
# o = OptionDescription('o', '', [b, b2, b3])
|
||||||
o1 = OptionDescription('o1', '', [o])
|
# o1 = OptionDescription('o1', '', [o])
|
||||||
o1.impl_build_cache()
|
# o1.impl_build_cache()
|
||||||
|
#
|
||||||
a = dumps(o1)
|
# a = dumps(o1)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_diff_opt(o1, q)
|
# _diff_opt(o1, q)
|
||||||
_diff_opt(o1.o, q.o)
|
# _diff_opt(o1.o, q.o)
|
||||||
_diff_opt(o1.o.b, q.o.b)
|
# _diff_opt(o1.o.b, q.o.b)
|
||||||
_diff_opt(o1.o.b2, q.o.b2)
|
# _diff_opt(o1.o.b2, q.o.b2)
|
||||||
_diff_opt(o1.o.b3, q.o.b3)
|
# _diff_opt(o1.o.b3, q.o.b3)
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_no_state_attr():
|
#def test_no_state_attr():
|
||||||
# all _state_xxx attributes should be deleted
|
# # all _state_xxx attributes should be deleted
|
||||||
b = BoolOption('b', '')
|
# b = BoolOption('b', '')
|
||||||
u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
# u = UnicodeOption('u', '', requires=[{'option': b, 'expected': True, 'action': 'disabled', 'inverse': True}])
|
||||||
s = SymLinkOption('s', u)
|
# s = SymLinkOption('s', u)
|
||||||
o = OptionDescription('o', '', [b, u, s])
|
# o = OptionDescription('o', '', [b, u, s])
|
||||||
o1 = OptionDescription('o1', '', [o])
|
# o1 = OptionDescription('o1', '', [o])
|
||||||
|
#
|
||||||
a = dumps(o1)
|
# a = dumps(o1)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_no_state(q)
|
# _no_state(q)
|
||||||
_no_state(q.o)
|
# _no_state(q.o)
|
||||||
_no_state(q.o.b)
|
# _no_state(q.o.b)
|
||||||
_no_state(q.o.u)
|
# _no_state(q.o.u)
|
||||||
_no_state(q.o.s)
|
# _no_state(q.o.s)
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_state_config():
|
#def test_state_config():
|
||||||
val1 = BoolOption('val1', "")
|
# val1 = BoolOption('val1', "")
|
||||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
# maconfig = OptionDescription('rootconfig', '', [val1])
|
||||||
try:
|
# try:
|
||||||
cfg = Config(maconfig, persistent=True, session_id='29090931')
|
# cfg = Config(maconfig, persistent=True, session_id='29090931')
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
cfg = Config(maconfig, session_id='29090931')
|
# cfg = Config(maconfig, session_id='29090931')
|
||||||
cfg._impl_test = True
|
# cfg._impl_test = True
|
||||||
a = dumps(cfg)
|
# a = dumps(cfg)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_diff_conf(cfg, q)
|
# _diff_conf(cfg, q)
|
||||||
try:
|
# try:
|
||||||
delete_session('29090931')
|
# delete_session('29090931')
|
||||||
except ConfigError:
|
# except ConfigError:
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_state_properties():
|
#def test_state_properties():
|
||||||
val1 = BoolOption('val1', "")
|
# val1 = BoolOption('val1', "")
|
||||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
# maconfig = OptionDescription('rootconfig', '', [val1])
|
||||||
try:
|
# try:
|
||||||
cfg = Config(maconfig, persistent=True, session_id='29090932')
|
# cfg = Config(maconfig, persistent=True, session_id='29090932')
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
cfg = Config(maconfig, session_id='29090932')
|
# cfg = Config(maconfig, session_id='29090932')
|
||||||
cfg._impl_test = True
|
# cfg._impl_test = True
|
||||||
cfg.read_write()
|
# cfg.read_write()
|
||||||
cfg.cfgimpl_get_settings()[val1].append('test')
|
# cfg.cfgimpl_get_settings()[val1].append('test')
|
||||||
a = dumps(cfg)
|
# a = dumps(cfg)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_diff_conf(cfg, q)
|
# _diff_conf(cfg, q)
|
||||||
try:
|
# try:
|
||||||
delete_session('29090932')
|
# delete_session('29090932')
|
||||||
except ConfigError:
|
# except ConfigError:
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_state_values():
|
#def test_state_values():
|
||||||
val1 = BoolOption('val1', "")
|
# val1 = BoolOption('val1', "")
|
||||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
# maconfig = OptionDescription('rootconfig', '', [val1])
|
||||||
try:
|
# try:
|
||||||
cfg = Config(maconfig, persistent=True, session_id='29090933')
|
# cfg = Config(maconfig, persistent=True, session_id='29090933')
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
cfg = Config(maconfig, session_id='29090933')
|
# cfg = Config(maconfig, session_id='29090933')
|
||||||
cfg._impl_test = True
|
# cfg._impl_test = True
|
||||||
cfg.val1 = True
|
# cfg.val1 = True
|
||||||
a = dumps(cfg)
|
# a = dumps(cfg)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_diff_conf(cfg, q)
|
# _diff_conf(cfg, q)
|
||||||
q.val1 = False
|
# q.val1 = False
|
||||||
#assert cfg.val1 is True
|
# #assert cfg.val1 is True
|
||||||
assert q.val1 is False
|
# assert q.val1 is False
|
||||||
try:
|
# try:
|
||||||
delete_session('29090933')
|
# delete_session('29090933')
|
||||||
except ConfigError:
|
# except ConfigError:
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_state_values_owner():
|
#def test_state_values_owner():
|
||||||
val1 = BoolOption('val1', "")
|
# val1 = BoolOption('val1', "")
|
||||||
maconfig = OptionDescription('rootconfig', '', [val1])
|
# maconfig = OptionDescription('rootconfig', '', [val1])
|
||||||
try:
|
# try:
|
||||||
cfg = Config(maconfig, persistent=True, session_id='29090934')
|
# cfg = Config(maconfig, persistent=True, session_id='29090934')
|
||||||
except ValueError:
|
# except ValueError:
|
||||||
cfg = Config(maconfig, session_id='29090934')
|
# cfg = Config(maconfig, session_id='29090934')
|
||||||
cfg._impl_test = True
|
# cfg._impl_test = True
|
||||||
owners.addowner('newowner')
|
# owners.addowner('newowner')
|
||||||
cfg.cfgimpl_get_settings().setowner(owners.newowner)
|
# cfg.cfgimpl_get_settings().setowner(owners.newowner)
|
||||||
cfg.val1 = True
|
# cfg.val1 = True
|
||||||
a = dumps(cfg)
|
# a = dumps(cfg)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_diff_conf(cfg, q)
|
# _diff_conf(cfg, q)
|
||||||
q.val1 = False
|
# q.val1 = False
|
||||||
nval1 = q.cfgimpl_get_description().val1
|
# nval1 = q.cfgimpl_get_description().val1
|
||||||
assert q.getowner(nval1) == owners.newowner
|
# assert q.getowner(nval1) == owners.newowner
|
||||||
try:
|
# try:
|
||||||
delete_session('29090934')
|
# delete_session('29090934')
|
||||||
except ConfigError:
|
# except ConfigError:
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_state_metaconfig():
|
#def test_state_metaconfig():
|
||||||
i1 = IntOption('i1', '')
|
# i1 = IntOption('i1', '')
|
||||||
od1 = OptionDescription('od1', '', [i1])
|
# od1 = OptionDescription('od1', '', [i1])
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
# od2 = OptionDescription('od2', '', [od1])
|
||||||
conf1 = Config(od2, session_id='29090935')
|
# conf1 = Config(od2, session_id='29090935')
|
||||||
conf1._impl_test = True
|
# conf1._impl_test = True
|
||||||
conf2 = Config(od2, session_id='29090936')
|
# conf2 = Config(od2, session_id='29090936')
|
||||||
conf2._impl_test = True
|
# conf2._impl_test = True
|
||||||
meta = MetaConfig([conf1, conf2], session_id='29090937')
|
# meta = MetaConfig([conf1, conf2], session_id='29090937')
|
||||||
meta._impl_test = True
|
# meta._impl_test = True
|
||||||
raises(ConfigError, "dumps(meta)")
|
# raises(ConfigError, "dumps(meta)")
|
||||||
try:
|
# try:
|
||||||
delete_session('29090935')
|
# delete_session('29090935')
|
||||||
delete_session('29090936')
|
# delete_session('29090936')
|
||||||
delete_session('29090937')
|
# delete_session('29090937')
|
||||||
except ConfigError:
|
# except ConfigError:
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_state_groupconfig():
|
#def test_state_groupconfig():
|
||||||
i1 = IntOption('i1', '')
|
# i1 = IntOption('i1', '')
|
||||||
od1 = OptionDescription('od1', '', [i1])
|
# od1 = OptionDescription('od1', '', [i1])
|
||||||
od2 = OptionDescription('od2', '', [od1])
|
# od2 = OptionDescription('od2', '', [od1])
|
||||||
conf1 = Config(od2, session_id='29090935')
|
# conf1 = Config(od2, session_id='29090935')
|
||||||
conf1._impl_test = True
|
# conf1._impl_test = True
|
||||||
conf2 = Config(od2, session_id='29090936')
|
# conf2 = Config(od2, session_id='29090936')
|
||||||
conf2._impl_test = True
|
# conf2._impl_test = True
|
||||||
meta = GroupConfig([conf1, conf2], session_id='29090937')
|
# meta = GroupConfig([conf1, conf2], session_id='29090937')
|
||||||
meta._impl_test = True
|
# meta._impl_test = True
|
||||||
a = dumps(meta)
|
# a = dumps(meta)
|
||||||
q = loads(a)
|
# q = loads(a)
|
||||||
_diff_conf(meta, q)
|
# _diff_conf(meta, q)
|
||||||
try:
|
# try:
|
||||||
delete_session('29090935')
|
# delete_session('29090935')
|
||||||
delete_session('29090936')
|
# delete_session('29090936')
|
||||||
delete_session('29090937')
|
# delete_session('29090937')
|
||||||
except ConfigError:
|
# except ConfigError:
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
|
#
|
||||||
def test_state_unkown_setting_owner():
|
#def test_state_unkown_setting_owner():
|
||||||
"""load an unknow _owner, should create it"""
|
# """load an unknow _owner, should create it"""
|
||||||
assert not 'supernewuser' in owners.__dict__
|
# assert not 'supernewuser' in owners.__dict__
|
||||||
loads("""ccopy_reg
|
# loads("""ccopy_reg
|
||||||
_reconstructor
|
#_reconstructor
|
||||||
p0
|
#p0
|
||||||
(ctiramisu.setting
|
#(ctiramisu.setting
|
||||||
Settings
|
#Settings
|
||||||
p1
|
#p1
|
||||||
c__builtin__
|
#c__builtin__
|
||||||
object
|
#object
|
||||||
p2
|
#p2
|
||||||
Ntp3
|
#Ntp3
|
||||||
Rp4
|
#Rp4
|
||||||
(dp5
|
#(dp5
|
||||||
S'_owner'
|
#S'_owner'
|
||||||
p6
|
#p6
|
||||||
S'supernewuser'
|
#S'supernewuser'
|
||||||
p7
|
#p7
|
||||||
sS'_p_'
|
#sS'_p_'
|
||||||
p8
|
#p8
|
||||||
g0
|
#g0
|
||||||
(ctiramisu.storage.dictionary.setting
|
#(ctiramisu.storage.dictionary.setting
|
||||||
Settings
|
#Settings
|
||||||
p9
|
#p9
|
||||||
g2
|
#g2
|
||||||
Ntp10
|
#Ntp10
|
||||||
Rp11
|
#Rp11
|
||||||
(dp12
|
#(dp12
|
||||||
S'_cache'
|
#S'_cache'
|
||||||
p13
|
#p13
|
||||||
(dp14
|
#(dp14
|
||||||
sS'_permissives'
|
#sS'_permissives'
|
||||||
p15
|
#p15
|
||||||
(dp16
|
#(dp16
|
||||||
sS'_properties'
|
#sS'_properties'
|
||||||
p17
|
#p17
|
||||||
(dp18
|
#(dp18
|
||||||
sbsb.
|
#sbsb.
|
||||||
.""")
|
#.""")
|
||||||
assert 'supernewuser' in owners.__dict__
|
# assert 'supernewuser' in owners.__dict__
|
||||||
|
|
Loading…
Reference in New Issue