when change len of calculated master, change len of slave too
This commit is contained in:
@ -373,6 +373,9 @@ def test_callback_multi_value():
|
||||
assert cfg.val2 == ['val']
|
||||
assert cfg.val3 == ['yes']
|
||||
assert cfg.val4 == ['val', 'yes']
|
||||
cfg.val2.append('new')
|
||||
assert cfg.val1 == ['val']
|
||||
assert cfg.val2 == ['val', 'new']
|
||||
|
||||
|
||||
def test_callback_multi_list():
|
||||
@ -466,6 +469,66 @@ def test_callback_master_and_slaves_slave():
|
||||
assert cfg.val1.val2 == ['val2', 'val2', 'val']
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_slave_cal():
|
||||
val3 = StrOption('val3', "", multi=True)
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_val)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val3])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val3 == []
|
||||
assert cfg.val1.val1 == []
|
||||
assert cfg.val1.val2 == []
|
||||
cfg.val1.val1 = ['val1']
|
||||
cfg.val3 = ['val1']
|
||||
assert cfg.val1.val1 == ['val1']
|
||||
assert cfg.val1.val2 == ['val']
|
||||
assert cfg.val1.val1 == ['val1']
|
||||
assert cfg.val1.val2 == ['val']
|
||||
del(cfg.val1.val1)
|
||||
cfg.val1.val2 = ['val']
|
||||
cfg.val3 = ['val1', 'val2']
|
||||
assert cfg.val1.val2 == ['val', 'val']
|
||||
assert cfg.val1.val1 == ['val1', 'val2']
|
||||
cfg.val1.val2 = ['val1', 'val2']
|
||||
cfg.val3.pop(1)
|
||||
# cannot remove slave's value because master is calculated
|
||||
# so raise
|
||||
raises(SlaveError, "cfg.val1.val1")
|
||||
raises(SlaveError, "cfg.val1.val2")
|
||||
cfg.val3 = ['val1', 'val2', 'val3']
|
||||
assert cfg.val1.val2 == ['val1', 'val2', 'val']
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_slave_cal2():
|
||||
val3 = StrOption('val3', "", ['val', 'val'], multi=True)
|
||||
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params={'': ((val3, False),)})
|
||||
val2 = StrOption('val2', "", ['val2', 'val2'], multi=True)
|
||||
interface1 = OptionDescription('val1', '', [val1, val2])
|
||||
interface1.impl_set_group_type(groups.master)
|
||||
maconfig = OptionDescription('rootconfig', '', [interface1, val3])
|
||||
cfg = Config(maconfig)
|
||||
cfg.read_write()
|
||||
assert cfg.val3 == ['val', 'val']
|
||||
assert cfg.val1.val1 == ['val', 'val']
|
||||
assert cfg.val1.val2 == ['val2', 'val2']
|
||||
cfg.val3.pop(1)
|
||||
# # cannot remove slave's value because master is calculated
|
||||
# # so raise
|
||||
raises(SlaveError, "cfg.val1.val1")
|
||||
raises(SlaveError, "cfg.val1.val2")
|
||||
cfg.val3 = ['val', 'val']
|
||||
assert cfg.val3 == ['val', 'val']
|
||||
assert cfg.val1.val1 == ['val', 'val']
|
||||
assert cfg.val1.val2 == ['val2', 'val2']
|
||||
raises(SlaveError, "cfg.val1.val1 = ['val']")
|
||||
assert cfg.val3 == ['val', 'val']
|
||||
assert cfg.val1.val1 == ['val', 'val']
|
||||
assert cfg.val1.val2 == ['val2', 'val2']
|
||||
|
||||
|
||||
def test_callback_master_and_slaves_slave_list():
|
||||
val1 = StrOption('val1', "", multi=True)
|
||||
val2 = StrOption('val2', "", multi=True, callback=return_list)
|
||||
|
@ -249,3 +249,46 @@ def test_state_values_owner():
|
||||
delete_session('29090931')
|
||||
except ConfigError:
|
||||
pass
|
||||
|
||||
|
||||
def test_state_unkown_setting_owner():
|
||||
"""load an unknow _owner, should create it"""
|
||||
assert not 'supernewuser' in owners.__dict__
|
||||
loads("""ccopy_reg
|
||||
_reconstructor
|
||||
p0
|
||||
(ctiramisu.setting
|
||||
Settings
|
||||
p1
|
||||
c__builtin__
|
||||
object
|
||||
p2
|
||||
Ntp3
|
||||
Rp4
|
||||
(dp5
|
||||
S'_owner'
|
||||
p6
|
||||
S'supernewuser'
|
||||
p7
|
||||
sS'_p_'
|
||||
p8
|
||||
g0
|
||||
(ctiramisu.storage.dictionary.setting
|
||||
Settings
|
||||
p9
|
||||
g2
|
||||
Ntp10
|
||||
Rp11
|
||||
(dp12
|
||||
S'_cache'
|
||||
p13
|
||||
(dp14
|
||||
sS'_permissives'
|
||||
p15
|
||||
(dp16
|
||||
sS'_properties'
|
||||
p17
|
||||
(dp18
|
||||
sbsb.
|
||||
.""")
|
||||
assert 'supernewuser' in owners.__dict__
|
||||
|
Reference in New Issue
Block a user