2018-10-31 18:38:44 +01:00
|
|
|
from py.test import raises
|
2017-07-09 09:49:03 +02:00
|
|
|
from .autopath import do_autopath
|
2015-07-24 17:54:10 +02:00
|
|
|
do_autopath()
|
2013-09-17 09:02:10 +02:00
|
|
|
|
2014-12-01 21:49:50 +01:00
|
|
|
from tiramisu.setting import groups, owners
|
2019-02-10 20:59:03 +01:00
|
|
|
from tiramisu import IntOption, StrOption, NetworkOption, NetmaskOption, BoolOption, ChoiceOption, \
|
2019-02-23 19:06:23 +01:00
|
|
|
IPOption, OptionDescription, Leadership, Config, GroupConfig, MetaConfig, \
|
2018-08-15 08:35:22 +02:00
|
|
|
Params, ParamOption, ParamValue
|
2019-02-23 19:06:23 +01:00
|
|
|
from tiramisu.error import ConfigError, ConflictError, PropertiesOptionError, LeadershipError, APIError
|
2018-10-31 08:00:19 +01:00
|
|
|
from tiramisu.storage import list_sessions
|
|
|
|
|
|
|
|
|
|
|
|
def teardown_function(function):
|
|
|
|
assert list_sessions() == [], 'session list is not empty when leaving "{}"'.format(function.__name__)
|
|
|
|
|
2013-09-17 09:02:10 +02:00
|
|
|
|
2019-02-24 08:34:50 +01:00
|
|
|
owners.addowner('config')
|
2018-03-19 08:33:53 +01:00
|
|
|
owners.addowner('meta1')
|
|
|
|
owners.addowner('meta2')
|
2013-09-17 09:02:10 +02:00
|
|
|
|
|
|
|
|
2017-07-16 23:11:12 +02:00
|
|
|
def return_value(value=None):
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
2019-02-10 20:59:03 +01:00
|
|
|
def return_condition(val, condition, expected):
|
|
|
|
if condition == expected:
|
|
|
|
return val
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
2017-02-11 17:22:50 +01:00
|
|
|
def raise_exception():
|
|
|
|
raise Exception('test')
|
|
|
|
|
|
|
|
|
2013-09-17 09:02:10 +02:00
|
|
|
def make_description():
|
|
|
|
i1 = IntOption('i1', '')
|
|
|
|
i2 = IntOption('i2', '', default=1)
|
|
|
|
i3 = IntOption('i3', '')
|
|
|
|
i4 = IntOption('i4', '', default=2)
|
2014-02-04 21:14:30 +01:00
|
|
|
i5 = IntOption('i5', '', default=[2], multi=True)
|
|
|
|
i6 = IntOption('i6', '', properties=('disabled',))
|
|
|
|
od1 = OptionDescription('od1', '', [i1, i2, i3, i4, i5, i6])
|
2013-09-17 09:02:10 +02:00
|
|
|
od2 = OptionDescription('od2', '', [od1])
|
2017-07-21 18:03:34 +02:00
|
|
|
return od2
|
|
|
|
|
|
|
|
|
2018-03-19 08:33:53 +01:00
|
|
|
def make_metaconfig(double=False):
|
2017-07-21 18:03:34 +02:00
|
|
|
od2 = make_description()
|
2018-03-19 08:33:53 +01:00
|
|
|
conf1 = Config(od2, session_id='conf1')
|
|
|
|
conf2 = Config(od2, session_id='conf2')
|
|
|
|
meta = MetaConfig([conf1, conf2], session_id='meta')
|
|
|
|
if double:
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.owner.set(owners.meta2)
|
2018-08-17 22:12:50 +02:00
|
|
|
meta = MetaConfig([meta], session_id='doublemeta')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.property.read_write()
|
|
|
|
meta.owner.set(owners.meta1)
|
|
|
|
return meta
|
2013-09-17 09:02:10 +02:00
|
|
|
|
|
|
|
|
2018-04-10 22:42:20 +02:00
|
|
|
def test_unknown_config():
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = make_metaconfig()
|
|
|
|
raises(ConfigError, "meta.config('unknown')")
|
2018-04-10 22:42:20 +02:00
|
|
|
|
|
|
|
|
2019-02-06 21:47:11 +01:00
|
|
|
def test_path():
|
|
|
|
meta = make_metaconfig()
|
|
|
|
assert meta.config.path() == 'meta'
|
|
|
|
assert meta.config('conf1').config.path() == 'meta.conf1'
|
|
|
|
assert meta.config('conf2').config.path() == 'meta.conf2'
|
|
|
|
|
|
|
|
|
2013-09-17 09:02:10 +02:00
|
|
|
#FIXME ne pas mettre 2 meta dans une config
|
|
|
|
#FIXME ne pas mettre 2 OD differents dans un meta
|
|
|
|
def test_none():
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = make_metaconfig()
|
|
|
|
assert meta.option('od1.i3').value.get() is meta.config('conf1').option('od1.i3').value.get() is meta.config('conf2').option('od1.i3').value.get() is None
|
|
|
|
assert meta.option('od1.i3').owner.get() is meta.config('conf1').option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.default
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('od1.i3').value.set(3)
|
|
|
|
assert meta.option('od1.i3').value.get() == meta.config('conf1').option('od1.i3').value.get() == meta.config('conf2').option('od1.i3').value.get() == 3
|
|
|
|
assert meta.option('od1.i3').owner.get() is meta.config('conf1').option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('od1.i3').value.set(2)
|
|
|
|
assert meta.option('od1.i3').value.get() == meta.config('conf2').option('od1.i3').value.get() == 3
|
|
|
|
assert meta.config('conf1').option('od1.i3').value.get() == 2
|
|
|
|
assert meta.option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
|
|
|
assert meta.config('conf1').option('od1.i3').owner.get() is owners.user
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('od1.i3').value.set(4)
|
|
|
|
assert meta.option('od1.i3').value.get() == meta.config('conf2').option('od1.i3').value.get() == 4
|
|
|
|
assert meta.config('conf1').option('od1.i3').value.get() == 2
|
|
|
|
assert meta.option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.meta1
|
|
|
|
assert meta.config('conf1').option('od1.i3').owner.get() is owners.user
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('od1.i3').value.reset()
|
|
|
|
assert meta.option('od1.i3').value.get() is meta.config('conf2').option('od1.i3').value.get() is None
|
|
|
|
assert meta.config('conf1').option('od1.i3').value.get() == 2
|
|
|
|
assert meta.option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.default
|
|
|
|
assert meta.config('conf1').option('od1.i3').owner.get() is owners.user
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('od1.i3').value.reset()
|
|
|
|
assert meta.option('od1.i3').value.get() is meta.config('conf1').option('od1.i3').value.get() is meta.config('conf2').option('od1.i3').value.get() is None
|
|
|
|
assert meta.option('od1.i3').owner.get() is meta.config('conf1').option('od1.i3').owner.get() is meta.config('conf2').option('od1.i3').owner.get() is owners.default
|
2018-09-22 17:45:52 +02:00
|
|
|
#
|
|
|
|
assert meta.config(None).config.name() == meta.config.name()
|
|
|
|
|
|
|
|
|
|
|
|
def test_reset():
|
|
|
|
meta = make_metaconfig()
|
|
|
|
assert meta.option('od1.i2').value.get() == 1
|
|
|
|
meta.option('od1.i2').value.set(2)
|
|
|
|
meta.config('conf1').option('od1.i2').value.set(3)
|
|
|
|
assert meta.option('od1.i2').value.get() == 2
|
|
|
|
assert meta.config('conf1').option('od1.i2').value.get() == 3
|
|
|
|
assert meta.config('conf2').option('od1.i2').value.get() == 2
|
|
|
|
meta.config.reset()
|
|
|
|
assert meta.option('od1.i2').value.get() == 1
|
|
|
|
assert meta.config('conf1').option('od1.i2').value.get() == 3
|
|
|
|
assert meta.config('conf2').option('od1.i2').value.get() == 1
|
2013-09-17 09:02:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_default():
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = make_metaconfig()
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('conf1').option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 1
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('conf1').option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.default
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('od1.i2').value.set(3)
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('conf1').option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 3
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('conf1').option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('od1.i2').value.set(2)
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 3
|
|
|
|
assert meta.config('conf1').option('od1.i2').value.get() == 2
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
|
|
|
assert meta.config('conf1').option('od1.i2').owner.get() is owners.user
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('od1.i2').value.set(4)
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 4
|
|
|
|
assert meta.config('conf1').option('od1.i2').value.get() == 2
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.meta1
|
|
|
|
assert meta.config('conf1').option('od1.i2').owner.get() is owners.user
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('od1.i2').value.reset()
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 1
|
|
|
|
assert meta.config('conf1').option('od1.i2').value.get() == 2
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.default
|
|
|
|
assert meta.config('conf1').option('od1.i2').owner.get() is owners.user
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('od1.i2').value.reset()
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('conf1').option('od1.i2').value.get() == meta.config('conf2').option('od1.i2').value.get() == 1
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('conf1').option('od1.i2').owner.get() is meta.config('conf2').option('od1.i2').owner.get() is owners.default
|
2013-09-17 09:02:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_contexts():
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = make_metaconfig()
|
|
|
|
errors = meta.value.set('od1.i2', 6, only_config=True)
|
|
|
|
assert meta.option('od1.i2').value.get() == 1
|
|
|
|
assert meta.option('od1.i2').owner.get() == owners.default
|
|
|
|
assert meta.config('conf1').option('od1.i2').value.get() == meta.config('conf1').option('od1.i2').value.get() == 6
|
|
|
|
assert meta.config('conf1').option('od1.i2').owner.get() == meta.config('conf1').option('od1.i2').owner.get() is owners.user
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2013-09-17 09:02:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_find():
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = make_metaconfig()
|
2018-10-07 10:55:52 +02:00
|
|
|
ret = list(meta.option.find('i2'))
|
2018-04-10 12:33:51 +02:00
|
|
|
assert len(ret) == 1
|
|
|
|
assert 1 == ret[0].value.get()
|
2018-08-15 08:35:22 +02:00
|
|
|
assert 1 == meta.option.find('i2', first=True).value.get()
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.value.dict() == {'od1.i4': 2, 'od1.i1': None, 'od1.i3': None,
|
2018-03-19 08:33:53 +01:00
|
|
|
'od1.i2': 1, 'od1.i5': [2]}
|
2013-09-17 09:02:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_meta():
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = make_metaconfig(double=True)
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf1').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 1
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf1').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
|
|
|
#
|
|
|
|
meta.option('od1.i2').value.set(3)
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf1').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 3
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf1').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
|
|
|
#
|
|
|
|
meta.config('meta.conf1').option('od1.i2').value.set(2)
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 3
|
|
|
|
assert meta.config('meta.conf1').option('od1.i2').value.get() == 2
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
|
|
|
assert meta.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
|
|
|
#
|
|
|
|
meta.config('meta').option('od1.i2').value.set(4)
|
|
|
|
assert meta.option('od1.i2').value.get() == 3
|
|
|
|
assert meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 4
|
|
|
|
assert meta.config('meta.conf1').option('od1.i2').value.get() == 2
|
|
|
|
assert meta.option('od1.i2').owner.get() is owners.meta1
|
|
|
|
assert meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.meta2
|
|
|
|
assert meta.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
|
|
|
#
|
|
|
|
meta.config('meta').option('od1.i2').value.reset()
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 3
|
|
|
|
assert meta.config('meta.conf1').option('od1.i2').value.get() == 2
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.meta1
|
|
|
|
assert meta.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
|
|
|
#
|
|
|
|
meta.option('od1.i2').value.reset()
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 1
|
|
|
|
assert meta.config('meta.conf1').option('od1.i2').value.get() == 2
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
|
|
|
assert meta.config('meta.conf1').option('od1.i2').owner.get() is owners.user
|
|
|
|
#
|
|
|
|
meta.config('meta.conf1').option('od1.i2').value.reset()
|
|
|
|
assert meta.option('od1.i2').value.get() == meta.config('meta').option('od1.i2').value.get() == meta.config('meta.conf1').option('od1.i2').value.get() == meta.config('meta.conf2').option('od1.i2').value.get() == 1
|
|
|
|
assert meta.option('od1.i2').owner.get() is meta.config('meta').option('od1.i2').owner.get() is meta.config('meta.conf1').option('od1.i2').owner.get() is meta.config('meta.conf2').option('od1.i2').owner.get() is owners.default
|
2017-07-21 18:03:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_new_config():
|
2018-03-19 08:33:53 +01:00
|
|
|
od = make_description()
|
|
|
|
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
2018-08-14 22:25:31 +02:00
|
|
|
assert len(list(meta.config.list())) == 2
|
2018-08-14 22:15:40 +02:00
|
|
|
meta.config.new('newconf1')
|
2018-08-14 22:25:31 +02:00
|
|
|
assert len(list(meta.config.list())) == 3
|
2017-07-21 18:03:34 +02:00
|
|
|
|
|
|
|
|
2018-09-15 10:45:36 +02:00
|
|
|
def test_meta_new_config_owner():
|
|
|
|
od = make_description()
|
|
|
|
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
|
|
|
meta.owner.set('meta')
|
|
|
|
meta.config.new('newconf1')
|
|
|
|
assert meta.owner.get() == 'meta'
|
|
|
|
|
|
|
|
|
2018-09-15 10:34:15 +02:00
|
|
|
def test_meta_new_metaconfig():
|
|
|
|
od = make_description()
|
|
|
|
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
|
|
|
meta.config.new('newconf1', type='metaconfig')
|
|
|
|
meta.config('newconf1').config.new('newconf2', type='metaconfig')
|
|
|
|
meta.config('newconf1').config('newconf2').config.new('newconf3')
|
|
|
|
assert meta.config('newconf1').config('newconf2').config('newconf3').config.name() == 'newconf3'
|
|
|
|
|
|
|
|
|
2018-09-13 07:00:12 +02:00
|
|
|
def test_meta_pop_config():
|
|
|
|
od = make_description()
|
|
|
|
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
|
|
|
assert len(list(meta.config.list())) == 2
|
|
|
|
meta.config.new('newconf1')
|
|
|
|
assert len(list(meta.config.list())) == 3
|
|
|
|
meta.config.pop('newconf1')
|
|
|
|
assert len(list(meta.config.list())) == 2
|
|
|
|
raises(ConfigError, "meta.config.pop('newconf1')")
|
|
|
|
|
|
|
|
|
2017-07-21 18:03:34 +02:00
|
|
|
def test_meta_new_config_wrong_name():
|
2018-03-19 08:33:53 +01:00
|
|
|
od = make_description()
|
|
|
|
meta = MetaConfig(['name1', 'name2'], optiondescription=od)
|
2018-08-14 22:25:31 +02:00
|
|
|
assert len(list(meta.config.list())) == 2
|
2018-08-14 22:15:40 +02:00
|
|
|
raises(ConflictError, "meta.config.new('name1')")
|
2018-08-14 22:25:31 +02:00
|
|
|
assert len(list(meta.config.list())) == 2
|
2017-07-21 18:03:34 +02:00
|
|
|
|
|
|
|
|
2013-09-17 09:02:10 +02:00
|
|
|
def test_meta_meta_set():
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = make_metaconfig(double=True)
|
|
|
|
errors1 = meta.value.set('od1.i1', 7, only_config=True)
|
|
|
|
errors2 = meta.value.set('od1.i6', 7, only_config=True)
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors1) == 0
|
|
|
|
assert len(errors2) == 2
|
2018-09-08 20:17:20 +02:00
|
|
|
conf1 = meta.config('meta.conf1')._config_bag.context
|
|
|
|
conf2 = meta.config('meta.conf2')._config_bag.context
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.config('meta.conf1').option('od1.i1').value.get() == meta.config('meta.conf2').option('od1.i1').value.get() == 7
|
2018-08-17 22:12:50 +02:00
|
|
|
#
|
|
|
|
dconfigs = []
|
2018-10-07 16:29:56 +02:00
|
|
|
for conf in meta.config.find('i1', value=7).config.list():
|
2018-09-08 20:17:20 +02:00
|
|
|
dconfigs.append(conf._config_bag.context)
|
2018-08-17 22:12:50 +02:00
|
|
|
assert [conf1, conf2] == dconfigs
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('meta.conf1').option('od1.i1').value.set(8)
|
2018-08-17 22:12:50 +02:00
|
|
|
#
|
|
|
|
dconfigs = []
|
2018-10-07 16:29:56 +02:00
|
|
|
for conf in meta.config.find('i1').config.list():
|
2018-09-08 20:17:20 +02:00
|
|
|
dconfigs.append(conf._config_bag.context)
|
2018-08-17 22:12:50 +02:00
|
|
|
assert [conf1, conf2] == dconfigs
|
2018-10-07 16:29:56 +02:00
|
|
|
assert conf2 == list(meta.config.find('i1', value=7).config.list())[0]._config_bag.context
|
|
|
|
assert conf1 == list(meta.config.find('i1', value=8).config.list())[0]._config_bag.context
|
2018-08-17 22:12:50 +02:00
|
|
|
#
|
|
|
|
dconfigs = []
|
2018-10-07 16:29:56 +02:00
|
|
|
for conf in meta.config.find('i5', value=2).config.list():
|
2018-09-08 20:17:20 +02:00
|
|
|
dconfigs.append(conf._config_bag.context)
|
2018-08-17 22:12:50 +02:00
|
|
|
assert [conf1, conf2] == dconfigs
|
|
|
|
#
|
2018-10-07 16:29:56 +02:00
|
|
|
raises(AttributeError, "meta.config.find('i1', value=10)")
|
|
|
|
raises(AttributeError, "meta.config.find('not', value=10)")
|
|
|
|
raises(AttributeError, "meta.config.find('i6')")
|
2018-08-15 08:35:22 +02:00
|
|
|
raises(ValueError, "meta.value.set('od1.i6', 7, only_config=True, force_default=True)")
|
|
|
|
raises(ValueError, "meta.value.set('od1.i6', 7, only_config=True, force_default_if_same=True)")
|
|
|
|
raises(ValueError, "meta.value.set('od1.i6', 7, only_config=True, force_dont_change_value=True)")
|
2013-09-17 09:02:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_not_meta():
|
|
|
|
i1 = IntOption('i1', '')
|
|
|
|
od1 = OptionDescription('od1', '', [i1])
|
|
|
|
od2 = OptionDescription('od2', '', [od1])
|
2017-07-19 20:44:38 +02:00
|
|
|
conf1 = Config(od2, session_id='conf1')
|
|
|
|
conf2 = Config(od2, session_id='conf2')
|
2014-12-01 21:49:50 +01:00
|
|
|
conf3 = Config(od2)
|
2018-03-19 08:33:53 +01:00
|
|
|
conf4 = Config(od2, session_id='conf4')
|
2018-08-14 22:15:40 +02:00
|
|
|
raises(TypeError, "GroupConfig(conf1)")
|
2018-03-19 08:33:53 +01:00
|
|
|
#same name
|
2018-09-26 22:29:08 +02:00
|
|
|
#raises(ConflictError, "GroupConfig([conf2, conf4], session_id='conf2')")
|
2018-04-11 16:36:15 +02:00
|
|
|
raises(ConflictError, "GroupConfig([conf2, conf2], session_id='conf8')")
|
2018-03-19 08:33:53 +01:00
|
|
|
grp = GroupConfig([conf1, conf2])
|
2018-09-29 18:52:13 +02:00
|
|
|
raises(APIError, "grp.option('od1.i1').value.get()")
|
2018-08-14 22:15:40 +02:00
|
|
|
conf1, conf2 = grp.config.list()
|
2018-08-15 08:35:22 +02:00
|
|
|
errors = grp.value.set('od1.i1', 7)
|
2018-03-19 08:33:53 +01:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert grp.config('conf1').option('od1.i1').value.get() == grp.config('conf2').option('od1.i1').value.get() == 7
|
|
|
|
assert grp.config('conf1').option('od1.i1').owner.get() is grp.config('conf2').option('od1.i1').owner.get() is owners.user
|
2018-09-29 18:52:13 +02:00
|
|
|
grp.option('od1.i1').value.reset()
|
|
|
|
assert grp.config('conf1').option('od1.i1').owner.get() is grp.config('conf2').option('od1.i1').owner.get() is owners.default
|
2013-09-17 09:02:10 +02:00
|
|
|
|
|
|
|
|
2014-11-10 21:00:30 +01:00
|
|
|
def test_group_find_firsts():
|
|
|
|
i1 = IntOption('i1', '')
|
|
|
|
od1 = OptionDescription('od1', '', [i1])
|
|
|
|
od2 = OptionDescription('od2', '', [od1])
|
2017-07-19 20:44:38 +02:00
|
|
|
conf1 = Config(od2, session_id='conf1')
|
|
|
|
conf2 = Config(od2, session_id='conf2')
|
2014-12-01 21:49:50 +01:00
|
|
|
grp = GroupConfig([conf1, conf2])
|
2018-10-07 16:29:56 +02:00
|
|
|
itr = grp.config.find('i1').config.list()
|
2018-09-08 20:17:20 +02:00
|
|
|
conf1._config_bag.context == next(itr)._config_bag.context
|
|
|
|
conf2._config_bag.context == next(itr)._config_bag.context
|
2018-10-07 16:29:56 +02:00
|
|
|
try:
|
|
|
|
next(itr)
|
|
|
|
except StopIteration:
|
|
|
|
pass
|
|
|
|
except:
|
|
|
|
raise Exception('no')
|
|
|
|
else:
|
|
|
|
raise Exception('no')
|
2014-11-10 21:00:30 +01:00
|
|
|
|
|
|
|
|
2015-11-24 10:58:19 +01:00
|
|
|
def test_group_group():
|
|
|
|
i1 = IntOption('i1', '')
|
|
|
|
od1 = OptionDescription('od1', '', [i1])
|
|
|
|
od2 = OptionDescription('od2', '', [od1])
|
2017-07-19 20:44:38 +02:00
|
|
|
conf1 = Config(od2, session_id='conf9')
|
|
|
|
conf2 = Config(od2, session_id='conf10')
|
2015-11-24 10:58:19 +01:00
|
|
|
grp = GroupConfig([conf1, conf2], 'grp')
|
|
|
|
grp2 = GroupConfig([grp])
|
2018-08-15 08:35:22 +02:00
|
|
|
errors = grp2.value.set('od1.i1', 2)
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert grp2.config('grp.conf9').option('od1.i1').value.get() == 2
|
|
|
|
assert grp2.config('grp.conf9').option('od1.i1').owner.get() is owners.user
|
2014-02-02 22:47:46 +01:00
|
|
|
|
|
|
|
|
2019-02-06 21:47:11 +01:00
|
|
|
def test_group_group_path():
|
|
|
|
i1 = IntOption('i1', '')
|
|
|
|
od1 = OptionDescription('od1', '', [i1])
|
|
|
|
od2 = OptionDescription('od2', '', [od1])
|
|
|
|
conf1 = Config(od2, session_id='conf9')
|
|
|
|
conf2 = Config(od2, session_id='conf10')
|
|
|
|
grp = GroupConfig([conf1, conf2], 'grp')
|
|
|
|
grp2 = GroupConfig([grp], 'grp2')
|
|
|
|
assert grp2.config.path() == 'grp2'
|
|
|
|
assert grp2.config('grp').config.path() == 'grp'
|
|
|
|
assert grp2.config('grp.conf9').config.path() == 'conf9'
|
|
|
|
assert grp2.config('grp.conf10').config.path() == 'conf10'
|
|
|
|
|
|
|
|
|
2014-02-02 22:47:46 +01:00
|
|
|
def test_meta_unconsistent():
|
|
|
|
i1 = IntOption('i1', '')
|
|
|
|
i2 = IntOption('i2', '', default=1)
|
|
|
|
i3 = IntOption('i3', '')
|
|
|
|
i4 = IntOption('i4', '', default=2)
|
|
|
|
od1 = OptionDescription('od1', '', [i1, i2, i3, i4])
|
|
|
|
od2 = OptionDescription('od2', '', [od1])
|
2018-11-13 22:10:01 +01:00
|
|
|
i5 = IntOption('i5', '')
|
|
|
|
od3 = OptionDescription('od3', '', [i5])
|
2018-03-19 08:33:53 +01:00
|
|
|
conf1 = Config(od2, session_id='conf1')
|
|
|
|
conf2 = Config(od2, session_id='conf2')
|
|
|
|
conf3 = Config(od2, session_id='conf3')
|
|
|
|
conf4 = Config(od3, session_id='conf4')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.owner.set(owners.meta1)
|
2014-02-02 22:47:46 +01:00
|
|
|
raises(TypeError, 'MetaConfig("string")')
|
2014-12-01 21:49:50 +01:00
|
|
|
#same descr but conf1 already in meta
|
2014-02-02 22:47:46 +01:00
|
|
|
raises(ValueError, "MetaConfig([conf1, conf3])")
|
2014-12-01 21:49:50 +01:00
|
|
|
#not same descr
|
2014-02-02 22:47:46 +01:00
|
|
|
raises(ValueError, "MetaConfig([conf3, conf4])")
|
2014-12-01 21:49:50 +01:00
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_meta_leadership():
|
2014-12-01 21:49:50 +01:00
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_only()
|
2018-10-07 16:29:56 +02:00
|
|
|
itr = meta.config.find('ip_admin_eth0').config.list()
|
2018-09-08 20:17:20 +02:00
|
|
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
|
|
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
2018-10-07 16:29:56 +02:00
|
|
|
itr = meta.config.find('netmask_admin_eth0').config.list()
|
2018-09-08 20:17:20 +02:00
|
|
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
|
|
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.property.read_write()
|
2018-10-07 16:29:56 +02:00
|
|
|
raises(AttributeError, "meta.config.find('netmask_admin_eth0')")
|
|
|
|
itr = meta.unrestraint.config.find('netmask_admin_eth0').config.list()
|
2018-09-08 20:17:20 +02:00
|
|
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
|
|
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.property.read_only()
|
2018-10-07 16:29:56 +02:00
|
|
|
itr = meta.config.find('netmask_admin_eth0').config.list()
|
2018-09-08 20:17:20 +02:00
|
|
|
assert conf1._config_bag.context == next(itr)._config_bag.context
|
|
|
|
assert conf2._config_bag.context == next(itr)._config_bag.context
|
2014-12-01 21:49:50 +01:00
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_meta_leadership_value2():
|
2014-12-01 21:49:50 +01:00
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
|
|
|
meta = MetaConfig([conf1, conf2], session_id="meta")
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.8'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
|
|
#FIXME devrait raise ! assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0', 0).value.get() == None
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
|
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
|
|
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
2014-12-01 21:49:50 +01:00
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_meta_leadership_value_default():
|
2016-01-03 13:23:15 +01:00
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True, default=['192.168.1.1'])
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True)
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.255.0'
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == '255.255.0.0'
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
2016-01-03 13:23:15 +01:00
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_meta_leadership_owners():
|
2014-12-01 21:49:50 +01:00
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.owner.set(owners.meta1)
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
2019-02-23 19:06:23 +01:00
|
|
|
raises(LeadershipError, "meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()")
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.isdefault()
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.255.0')
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.meta1
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set('255.255.0.0')
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.meta1
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.meta1
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.1'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() == owners.user
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.netmask_admin_eth0', 0).owner.get() == owners.default
|
2014-12-01 21:49:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_force_default():
|
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
|
|
|
meta.owner.set('meta1')
|
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
#
|
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.3'])
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
2018-03-19 08:33:53 +01:00
|
|
|
#
|
2018-08-15 08:35:22 +02:00
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True)
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
2014-12-01 21:49:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_force_dont_change_value():
|
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
|
|
|
meta.owner.set('meta1')
|
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_dont_change_value=True)
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
2014-12-01 21:49:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_force_default_if_same():
|
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
|
|
|
meta.owner.set('meta1')
|
|
|
|
#
|
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
#
|
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True)
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
|
|
|
#
|
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True)
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
2014-12-01 21:49:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_force_default_if_same_and_dont_change():
|
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
|
|
|
meta.owner.set('meta1')
|
|
|
|
#
|
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
#
|
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.4'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.isdefault()
|
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default_if_same=True, force_dont_change_value=True)
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.4']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.meta1
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
#
|
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.3'])
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.5'], force_default_if_same=True, force_dont_change_value=True)
|
2017-07-21 18:03:34 +02:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.5']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.3']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').owner.get() is owners.user
|
2014-12-01 21:49:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_force_default_and_dont_change():
|
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='rconf1')
|
|
|
|
conf2 = Config(od, session_id='rconf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
|
|
|
meta.owner.set('meta1')
|
|
|
|
raises(ValueError, "meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.4'], force_default=True, force_dont_change_value=True)")
|
2017-02-11 17:22:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_properties_meta():
|
|
|
|
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',))
|
|
|
|
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-09-06 19:28:04 +02:00
|
|
|
conf1.property.read_write()
|
|
|
|
conf2.property.read_write()
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('conf1').value.dict() == {}
|
2017-02-11 17:22:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_exception_meta():
|
|
|
|
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, callback=raise_exception)
|
|
|
|
netmask_admin_eth0.impl_add_consistency('network_netmask', ip_admin_eth0)
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
2017-02-11 17:22:50 +01:00
|
|
|
raises(Exception, "conf1.make_dict()")
|
2017-07-16 23:11:12 +02:00
|
|
|
|
|
|
|
|
2019-02-10 20:59:03 +01:00
|
|
|
def test_meta_properties_requires_mandatory():
|
|
|
|
probes = BoolOption('probes', 'probes available', False)
|
|
|
|
eth0_method = ChoiceOption('eth0_method', '', ('static', 'dhcp'), 'static')
|
|
|
|
ip_address = IPOption('ip_address', '')
|
|
|
|
ip_eth0 = IPOption('ip_eth0', "ip", requires=({'option': probes, 'expected': True, 'action': 'mandatory'},), callback=return_condition, callback_params=Params(kwargs={'val': ParamOption(ip_address), 'condition': ParamOption(eth0_method), 'expected': ParamValue('dhcp')}))
|
|
|
|
ip_gw = IPOption('ip_gw', 'gw')
|
|
|
|
ip_gw.impl_add_consistency('not_equal', ip_eth0)
|
|
|
|
od = OptionDescription('root', '', [ip_gw, probes, eth0_method, ip_address, ip_eth0])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf1.property.read_write()
|
|
|
|
meta = MetaConfig([conf1], 'meta')
|
|
|
|
#
|
|
|
|
meta.option('probes').value.set(True)
|
|
|
|
meta.option('ip_address').value.set('1.1.1.1')
|
|
|
|
meta.option('ip_gw').value.set('1.1.1.2')
|
|
|
|
conf1.option('eth0_method').value.set('dhcp')
|
|
|
|
conf1.property.read_only()
|
|
|
|
assert conf1.value.dict(fullpath=True) == {'probes': True, 'eth0_method': 'dhcp', 'ip_address': '1.1.1.1', 'ip_eth0': '1.1.1.1', 'ip_gw': '1.1.1.2'}
|
|
|
|
|
|
|
|
|
2017-07-16 23:11:12 +02:00
|
|
|
def test_meta_callback():
|
|
|
|
val1 = StrOption('val1', "", 'val')
|
2018-04-15 21:13:16 +02:00
|
|
|
val2 = StrOption('val2', "", callback=return_value, callback_params=Params(ParamOption(val1)))
|
|
|
|
val3 = StrOption('val3', "", callback=return_value, callback_params=Params(ParamValue('yes')))
|
|
|
|
val4 = StrOption('val4', "", callback=return_value, callback_params=Params(kwargs={'value': ParamOption(val1)}))
|
|
|
|
val5 = StrOption('val5', "", callback=return_value, callback_params=Params(kwargs={'value': ParamValue('yes')}))
|
2017-07-16 23:11:12 +02:00
|
|
|
maconfig = OptionDescription('rootconfig', '', [val1, val2, val3, val4, val5])
|
2017-07-19 20:44:38 +02:00
|
|
|
cfg = Config(maconfig, session_id='cfg')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([cfg])
|
|
|
|
meta.property.read_write()
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'val', 'val1': 'val', 'val5': 'yes', 'val4': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('cfg').option('val1').value.set('new')
|
2018-10-31 08:00:19 +01:00
|
|
|
assert meta.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
|
|
|
meta.config('cfg').option('val1').value.reset()
|
|
|
|
meta.option('val1').value.set('new')
|
|
|
|
assert meta.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new'}
|
|
|
|
meta.config('cfg').option('val4').value.set('new1')
|
|
|
|
assert meta.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
|
|
|
meta.config('cfg').option('val4').value.reset()
|
|
|
|
meta.option('val4').value.set('new1')
|
|
|
|
assert meta.config('cfg').value.dict() == {'val3': 'yes', 'val2': 'new', 'val1': 'new', 'val5': 'yes', 'val4': 'new1'}
|
|
|
|
meta.option('val4').value.reset()
|
2017-07-16 23:11:12 +02:00
|
|
|
|
|
|
|
|
2019-02-23 19:06:23 +01:00
|
|
|
def test_meta_callback_follower():
|
2017-07-16 23:11:12 +02:00
|
|
|
val = StrOption('val', "", default='val')
|
2018-04-15 21:13:16 +02:00
|
|
|
val1 = StrOption('val1', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val)))
|
|
|
|
val3 = StrOption('val2', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
|
|
|
val4 = StrOption('val3', "", multi=True, callback=return_value, callback_params=Params(ParamOption(val1)))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('val1', '', [val1, val3, val4])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
2017-07-16 23:11:12 +02:00
|
|
|
maconfig = OptionDescription('rootconfig', '', [val, interface1])
|
2017-11-03 21:52:13 +01:00
|
|
|
cfg = Config(maconfig, session_id='cfg1')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([cfg])
|
|
|
|
meta.property.read_write()
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('cfg1').option('val').value.set('val1')
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('cfg1').option('val').value.reset()
|
|
|
|
meta.option('val').value.set('val1')
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val1'], 'val1.val1': ['val1'], 'val1.val3': ['val1'], 'val': 'val1'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('val').value.reset()
|
|
|
|
meta.config('cfg1').option('val1.val2', 0).value.set('val2')
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('cfg1').option('val1.val2', 0).value.reset()
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('val1.val2', 0).value.set('val2')
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('cfg1').option('val1.val3', 0).value.set('val6')
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val'], 'val1.val3': ['val6'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('val1.val2', 0).value.reset()
|
|
|
|
meta.config('cfg1').option('val1.val3', 0).value.reset()
|
|
|
|
meta.config('cfg1').option('val1.val1').value.set(['val3'])
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('cfg1').option('val1.val1').value.reset()
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val'], 'val1.val1': ['val'], 'val1.val3': ['val'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('val1.val1').value.set(['val3'])
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val3'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.config('cfg1').option('val1.val2', 0).value.set('val2')
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val3'], 'val1.val3': ['val3'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('val1.val1').value.set(['val3', 'rah'])
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val2', 'rah'], 'val1.val1': ['val3', 'rah'], 'val1.val3': ['val3', 'rah'], 'val': 'val'}
|
2018-08-15 08:35:22 +02:00
|
|
|
meta.option('val1.val1').value.pop(1)
|
|
|
|
meta.option('val1.val1').value.set(['val4'])
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('cfg1').value.dict() == {'val1.val2': ['val2'], 'val1.val1': ['val4'], 'val1.val3': ['val4'], 'val': 'val'}
|
2018-03-19 08:33:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_reset():
|
|
|
|
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip", multi=True)
|
|
|
|
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "mask", multi=True, properties=('hidden',))
|
2019-02-23 19:06:23 +01:00
|
|
|
interface1 = Leadership('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
2018-03-19 08:33:53 +01:00
|
|
|
od = OptionDescription('root', '', [interface1])
|
|
|
|
conf1 = Config(od, session_id='conf1')
|
|
|
|
conf2 = Config(od, session_id='conf2')
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
|
|
|
meta.owner.set('meta1')
|
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
errors = meta.value.set('ip_admin_eth0.ip_admin_eth0', ['192.168.1.1'])
|
2018-03-19 08:33:53 +01:00
|
|
|
assert len(errors) == 0
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
|
|
meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.1.2'])
|
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
2018-10-31 16:08:22 +01:00
|
|
|
meta.value.reset('ip_admin_eth0.ip_admin_eth0')
|
2018-08-15 08:35:22 +02:00
|
|
|
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
2017-07-19 20:44:38 +02:00
|
|
|
|
|
|
|
|
2018-09-05 20:22:16 +02:00
|
|
|
def test_meta_properties_meta_copy():
|
|
|
|
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')
|
2018-09-06 19:28:04 +02:00
|
|
|
conf1.property.read_write()
|
|
|
|
conf2.property.read_write()
|
2018-09-13 17:00:52 +02:00
|
|
|
meta = MetaConfig([conf1, conf2], session_id='meta1')
|
2018-09-05 20:22:16 +02:00
|
|
|
meta.property.read_write()
|
|
|
|
|
|
|
|
conf3 = meta.config('conf1').config.copy(session_id='conf3')
|
2018-09-13 17:00:52 +02:00
|
|
|
meta2 = conf3.config.metaconfig()
|
|
|
|
assert meta.config.name() == meta2.config.name()
|
2018-09-05 20:22:16 +02:00
|
|
|
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
|
|
assert meta.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
|
|
assert meta.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
2018-09-05 20:22:16 +02:00
|
|
|
meta.option('ip_admin_eth0').value.set(['192.168.1.2'])
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
|
|
assert meta.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
|
|
assert meta.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
2018-09-05 20:22:16 +02:00
|
|
|
ret = meta.value.set('ip_admin_eth0', ['192.168.1.3'], force_default_if_same=True)
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
|
|
assert meta.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
|
|
assert meta.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
2018-09-05 20:22:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_meta_properties_meta_deepcopy():
|
|
|
|
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')
|
2018-09-06 19:28:04 +02:00
|
|
|
conf1.property.read_write()
|
|
|
|
conf2.property.read_write()
|
2018-09-05 20:22:16 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.permissive.set(frozenset({'hidden'}))
|
|
|
|
meta.property.read_write()
|
|
|
|
|
2018-09-13 17:00:52 +02:00
|
|
|
meta2 = meta.config('conf1').config.deepcopy(session_id='conf3')
|
2018-09-05 20:22:16 +02:00
|
|
|
assert meta != meta2
|
|
|
|
assert meta.permissive.get() == meta2.permissive.get()
|
|
|
|
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
|
|
assert meta.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
|
|
|
assert meta2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
2018-09-05 20:22:16 +02:00
|
|
|
meta.option('ip_admin_eth0').value.set(['192.168.1.2'])
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
|
|
assert meta.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.2']}
|
|
|
|
assert meta2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
2018-09-05 20:22:16 +02:00
|
|
|
meta.value.set('ip_admin_eth0', ['192.168.1.3'], force_default_if_same=True)
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
|
|
assert meta.config('conf2').value.dict() == {'ip_admin_eth0': ['192.168.1.3']}
|
|
|
|
assert meta2.config('conf3').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
2018-09-05 20:22:16 +02:00
|
|
|
|
|
|
|
|
2018-09-13 17:00:52 +02:00
|
|
|
def test_meta_properties_submeta_deepcopy():
|
|
|
|
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')
|
|
|
|
conf1.property.read_write()
|
|
|
|
meta1 = MetaConfig([conf1], session_id='meta1')
|
|
|
|
meta2 = MetaConfig([meta1], session_id='meta2')
|
|
|
|
meta_copy = conf1.config.deepcopy(session_id='conf2',
|
|
|
|
metaconfig_prefix='copy_')
|
|
|
|
assert meta_copy.config.name() == 'copy_meta2'
|
|
|
|
assert meta_copy.config('copy_meta1').config.name() == 'copy_meta1'
|
|
|
|
assert meta_copy.config('copy_meta1').config('conf2').config.name() == 'conf2'
|
|
|
|
|
|
|
|
|
2018-09-15 10:34:15 +02:00
|
|
|
def test_meta_properties_submeta_deepcopy_owner():
|
|
|
|
ip_admin_eth0 = NetworkOption('ip_admin_eth0', "ip")
|
|
|
|
netmask_admin_eth0 = NetmaskOption('netmask_admin_eth0', "mask")
|
|
|
|
interface1 = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
|
|
|
conf1 = Config(interface1, session_id='conf1')
|
|
|
|
conf1.owner.set('conf1_user')
|
|
|
|
conf1.property.read_write()
|
|
|
|
meta1 = MetaConfig([conf1], session_id='meta1')
|
|
|
|
meta1.owner.set('meta1_user')
|
|
|
|
meta2 = MetaConfig([meta1], session_id='meta2')
|
|
|
|
meta2.owner.set('meta2_user')
|
|
|
|
#
|
|
|
|
conf1.option('ip_admin_eth0').value.set('192.168.0.1')
|
|
|
|
assert conf1.option('ip_admin_eth0').owner.get() == 'conf1_user'
|
|
|
|
meta1.option('ip_admin_eth0').value.set('192.168.0.2')
|
|
|
|
assert meta1.option('ip_admin_eth0').owner.get() == 'meta1_user'
|
|
|
|
meta2.option('ip_admin_eth0').value.set('192.168.0.3')
|
|
|
|
assert meta2.option('ip_admin_eth0').owner.get() == 'meta2_user'
|
|
|
|
#
|
|
|
|
meta2_copy = conf1.config.deepcopy(session_id='conf2',
|
|
|
|
metaconfig_prefix='copy_')
|
|
|
|
meta2_copy.option('netmask_admin_eth0').value.set('255.255.255.255')
|
|
|
|
assert meta2_copy.option('ip_admin_eth0').value.get() == '192.168.0.3'
|
|
|
|
assert meta2_copy.option('ip_admin_eth0').owner.get() == 'meta2_user'
|
|
|
|
assert meta2_copy.option('netmask_admin_eth0').owner.get() == 'meta2_user'
|
|
|
|
#
|
|
|
|
meta1_copy = meta2_copy.config('copy_meta1')
|
|
|
|
meta1_copy.option('netmask_admin_eth0').value.set('255.255.255.255')
|
|
|
|
assert meta1_copy.option('ip_admin_eth0').value.get() == '192.168.0.2'
|
|
|
|
assert meta1_copy.option('ip_admin_eth0').owner.get() == 'meta1_user'
|
|
|
|
assert meta1_copy.option('netmask_admin_eth0').owner.get() == 'meta1_user'
|
|
|
|
#
|
|
|
|
conf2 = meta1_copy.config('conf2')
|
|
|
|
conf2.owner.set('conf2_user')
|
|
|
|
conf2.option('netmask_admin_eth0').value.set('255.255.255.255')
|
|
|
|
assert conf2.option('netmask_admin_eth0').owner.get() == 'conf2_user'
|
|
|
|
assert conf2.option('ip_admin_eth0').value.get() == '192.168.0.1'
|
|
|
|
assert conf2.option('ip_admin_eth0').owner.get() == 'conf1_user'
|
|
|
|
|
|
|
|
|
2017-07-19 20:44:38 +02:00
|
|
|
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])
|
2018-03-19 08:33:53 +01:00
|
|
|
conf1 = Config(interface1, session_id='conf1')
|
|
|
|
conf2 = Config(interface1, session_id='conf2')
|
2018-09-06 19:28:04 +02:00
|
|
|
conf1.property.read_write()
|
|
|
|
conf2.property.read_write()
|
2018-08-15 08:35:22 +02:00
|
|
|
meta = MetaConfig([conf1, conf2])
|
|
|
|
meta.property.read_write()
|
2018-09-09 12:21:47 +02:00
|
|
|
assert meta.config('conf1').value.dict() == {'ip_admin_eth0': ['192.168.1.1']}
|
2018-08-15 08:35:22 +02:00
|
|
|
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], only_config=True)
|
2017-07-19 20:44:38 +02:00
|
|
|
assert len(ret) == 2
|
|
|
|
assert isinstance(ret[0], PropertiesOptionError)
|
|
|
|
assert isinstance(ret[1], PropertiesOptionError)
|
2018-10-31 08:00:19 +01:00
|
|
|
del ret[1]
|
|
|
|
del ret[0]
|
|
|
|
del ret
|
2018-08-15 08:35:22 +02:00
|
|
|
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default=True)
|
2017-07-19 20:44:38 +02:00
|
|
|
assert len(ret) == 1
|
|
|
|
assert isinstance(ret[0], PropertiesOptionError)
|
2018-10-31 08:00:19 +01:00
|
|
|
del ret[0]
|
|
|
|
del ret
|
2018-08-15 08:35:22 +02:00
|
|
|
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], force_dont_change_value=True)
|
2017-07-19 20:44:38 +02:00
|
|
|
assert len(ret) == 3
|
|
|
|
assert isinstance(ret[0], PropertiesOptionError)
|
|
|
|
assert isinstance(ret[1], PropertiesOptionError)
|
|
|
|
assert isinstance(ret[2], PropertiesOptionError)
|
2018-10-31 08:00:19 +01:00
|
|
|
del ret[2]
|
|
|
|
del ret[1]
|
|
|
|
del ret[0]
|
|
|
|
del ret
|
2018-08-15 08:35:22 +02:00
|
|
|
ret = meta.value.set('netmask_admin_eth0', ['255.255.255.255'], force_default_if_same=True)
|
2017-07-19 20:44:38 +02:00
|
|
|
assert len(ret) == 1
|
|
|
|
assert isinstance(ret[0], PropertiesOptionError)
|
2018-10-31 08:00:19 +01:00
|
|
|
del ret[0]
|
|
|
|
del ret
|
2018-08-15 08:35:22 +02:00
|
|
|
ret = meta.value.set('ip_admin_eth0', '255.255.255.255', only_config=True)
|
2017-07-19 20:44:38 +02:00
|
|
|
assert len(ret) == 2
|
|
|
|
assert isinstance(ret[0], ValueError)
|
|
|
|
assert isinstance(ret[1], ValueError)
|
2018-10-31 08:00:19 +01:00
|
|
|
del ret[1]
|
|
|
|
del ret[0]
|
|
|
|
del ret
|
2018-08-15 08:35:22 +02:00
|
|
|
ret = meta.value.set('ip_admin_eth0', '255.255.255.255', force_default=True)
|
2017-07-19 20:44:38 +02:00
|
|
|
assert len(ret) == 1
|
|
|
|
assert isinstance(ret[0], ValueError)
|
2018-10-31 08:00:19 +01:00
|
|
|
del ret[0]
|
|
|
|
del ret
|
2018-08-15 08:35:22 +02:00
|
|
|
ret = meta.value.set('ip_admin_eth0', '255.255.255.255', force_dont_change_value=True)
|
2017-07-19 20:44:38 +02:00
|
|
|
assert len(ret) == 1
|
|
|
|
assert isinstance(ret[0], ValueError)
|
2018-10-31 08:00:19 +01:00
|
|
|
del ret[0]
|
|
|
|
del ret
|
2018-08-15 08:35:22 +02:00
|
|
|
ret = meta.value.set('ip_admin_eth0', '255.255.255.255', force_default_if_same=True)
|
2017-07-19 20:44:38 +02:00
|
|
|
assert len(ret) == 1
|
|
|
|
assert isinstance(ret[0], ValueError)
|
2018-10-31 08:00:19 +01:00
|
|
|
del ret[0]
|
|
|
|
del ret
|
2019-02-23 22:10:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
def test_metaconfig_force_metaconfig_on_freeze():
|
2019-02-24 08:34:50 +01:00
|
|
|
dummy1 = StrOption('dummy1', 'doc dummy', default='default', properties=('force_metaconfig_on_freeze',))
|
|
|
|
group = OptionDescription('group', '', [dummy1])
|
|
|
|
config = Config(group, session_id='config')
|
|
|
|
config.owner.set(owners.config)
|
|
|
|
meta1 = MetaConfig([config], session_id='meta1')
|
|
|
|
meta1.owner.set(owners.meta1)
|
|
|
|
meta2 = MetaConfig([meta1], session_id='meta2')
|
|
|
|
meta2.owner.set(owners.meta2)
|
|
|
|
config.property.read_write()
|
|
|
|
|
|
|
|
config.option('dummy1').property.add('frozen')
|
|
|
|
#
|
|
|
|
assert config.option('dummy1').value.get() == 'default'
|
|
|
|
assert config.option('dummy1').owner.get() == 'default'
|
|
|
|
#
|
|
|
|
meta2.option('dummy1').value.set('meta2')
|
|
|
|
#
|
|
|
|
assert config.option('dummy1').value.get() == 'meta2'
|
|
|
|
assert config.option('dummy1').owner.get() == 'meta2'
|
|
|
|
#
|
|
|
|
config.option('dummy1').property.pop('frozen')
|
|
|
|
config.option('dummy1').value.set('config')
|
|
|
|
config.option('dummy1').property.add('frozen')
|
|
|
|
#
|
|
|
|
assert config.option('dummy1').value.get() == 'meta2'
|
|
|
|
assert config.option('dummy1').owner.get() == 'meta2'
|
|
|
|
#
|
|
|
|
meta1.option('dummy1').value.set('meta1')
|
|
|
|
#
|
|
|
|
assert config.option('dummy1').value.get() == 'meta1'
|
|
|
|
assert config.option('dummy1').owner.get() == 'meta1'
|
|
|
|
#
|
|
|
|
config.option('dummy1').property.pop('frozen')
|
|
|
|
assert config.option('dummy1').value.get() == 'config'
|
|
|
|
assert config.option('dummy1').owner.get() == 'config'
|
|
|
|
|
|
|
|
|
|
|
|
def test_metaconfig_force_metaconfig_on_freeze_option():
|
2019-02-23 22:10:43 +01:00
|
|
|
dummy1 = StrOption('dummy1', 'doc dummy', default='default')
|
|
|
|
dummy2 = StrOption('dummy2', 'doc dummy', default='default', properties=('force_default_on_freeze',))
|
|
|
|
group = OptionDescription('group', '', [dummy1, dummy2])
|
2019-02-24 08:34:50 +01:00
|
|
|
config = Config(group, session_id='config')
|
|
|
|
config.owner.set(owners.config)
|
2019-02-23 22:10:43 +01:00
|
|
|
meta1 = MetaConfig([config], session_id='meta1')
|
|
|
|
meta1.owner.set(owners.meta1)
|
|
|
|
meta2 = MetaConfig([meta1], session_id='meta2')
|
|
|
|
meta2.owner.set(owners.meta2)
|
|
|
|
config.property.read_write()
|
|
|
|
|
|
|
|
config.option('dummy1').property.add('frozen')
|
|
|
|
config.option('dummy1').property.add('force_metaconfig_on_freeze')
|
|
|
|
config.option('dummy2').property.add('frozen')
|
|
|
|
#
|
|
|
|
assert config.option('dummy1').value.get() == 'default'
|
|
|
|
assert config.option('dummy1').owner.get() == 'default'
|
|
|
|
assert config.option('dummy2').value.get() == 'default'
|
|
|
|
assert config.option('dummy2').owner.get() == 'default'
|
|
|
|
#
|
|
|
|
meta2.option('dummy1').value.set('meta2')
|
|
|
|
meta2.option('dummy2').value.set('meta2')
|
|
|
|
#
|
|
|
|
assert config.option('dummy1').value.get() == 'meta2'
|
|
|
|
assert config.option('dummy1').owner.get() == 'meta2'
|
|
|
|
assert config.option('dummy2').value.get() == 'default'
|
|
|
|
assert config.option('dummy2').owner.get() == 'default'
|
|
|
|
#
|
|
|
|
config.option('dummy1').property.pop('frozen')
|
|
|
|
config.option('dummy2').property.pop('frozen')
|
|
|
|
config.option('dummy1').value.set('config')
|
|
|
|
config.option('dummy2').value.set('config')
|
|
|
|
config.option('dummy1').property.add('frozen')
|
|
|
|
config.option('dummy2').property.add('frozen')
|
|
|
|
#
|
|
|
|
assert config.option('dummy1').value.get() == 'meta2'
|
|
|
|
assert config.option('dummy1').owner.get() == 'meta2'
|
|
|
|
assert config.option('dummy2').value.get() == 'default'
|
|
|
|
assert config.option('dummy2').owner.get() == 'default'
|
|
|
|
#
|
|
|
|
meta1.option('dummy1').value.set('meta1')
|
|
|
|
meta1.option('dummy2').value.set('meta1')
|
|
|
|
#
|
|
|
|
assert config.option('dummy1').value.get() == 'meta1'
|
|
|
|
assert config.option('dummy1').owner.get() == 'meta1'
|
|
|
|
assert config.option('dummy2').value.get() == 'default'
|
|
|
|
assert config.option('dummy2').owner.get() == 'default'
|
|
|
|
#
|
|
|
|
meta1.option('dummy1').property.add('force_metaconfig_on_freeze')
|
|
|
|
assert config.option('dummy1').value.get() == 'meta2'
|
|
|
|
assert config.option('dummy1').owner.get() == 'meta2'
|
|
|
|
#
|
|
|
|
meta2.option('dummy1').property.add('force_metaconfig_on_freeze')
|
|
|
|
assert config.option('dummy1').value.get() == 'default'
|
|
|
|
assert config.option('dummy1').owner.get() == 'default'
|
|
|
|
#
|
|
|
|
meta1.option('dummy1').property.pop('force_metaconfig_on_freeze')
|
|
|
|
assert config.option('dummy1').value.get() == 'meta1'
|
|
|
|
assert config.option('dummy1').owner.get() == 'meta1'
|
2019-02-24 08:34:50 +01:00
|
|
|
#
|
|
|
|
config.option('dummy1').property.pop('frozen')
|
|
|
|
assert config.option('dummy1').value.get() == 'config'
|
|
|
|
assert config.option('dummy1').owner.get() == 'config'
|