force_store_value now support Multi
This commit is contained in:
parent
22860099ba
commit
b6a0f188b2
|
@ -23,13 +23,14 @@ def make_description_freeze():
|
||||||
wantref_option = BoolOption('wantref', 'Test requires', default=False, properties=('force_store_value',),
|
wantref_option = BoolOption('wantref', 'Test requires', default=False, properties=('force_store_value',),
|
||||||
requires=({'option': booloption, 'expected': True, 'action': 'hidden'},))
|
requires=({'option': booloption, 'expected': True, 'action': 'hidden'},))
|
||||||
wantref2_option = BoolOption('wantref2', 'Test requires', default=False, properties=('force_store_value', 'hidden'))
|
wantref2_option = BoolOption('wantref2', 'Test requires', default=False, properties=('force_store_value', 'hidden'))
|
||||||
|
wantref3_option = BoolOption('wantref3', 'Test requires', default=[False], multi=True, properties=('force_store_value',))
|
||||||
wantframework_option = BoolOption('wantframework', 'Test requires',
|
wantframework_option = BoolOption('wantframework', 'Test requires',
|
||||||
default=False,
|
default=False,
|
||||||
requires=({'option': booloption, 'expected': True, 'action': 'hidden'},))
|
requires=({'option': booloption, 'expected': True, 'action': 'hidden'},))
|
||||||
|
|
||||||
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
|
||||||
descr = OptionDescription('tiramisu', '', [gcgroup, booloption, objspaceoption,
|
descr = OptionDescription('tiramisu', '', [gcgroup, booloption, objspaceoption,
|
||||||
wantref_option, wantref2_option, stroption,
|
wantref_option, wantref2_option, wantref3_option, stroption,
|
||||||
wantframework_option,
|
wantframework_option,
|
||||||
intoption, boolop])
|
intoption, boolop])
|
||||||
return descr
|
return descr
|
||||||
|
@ -207,7 +208,9 @@ def test_force_store_value_modified():
|
||||||
conf = Config(descr)
|
conf = Config(descr)
|
||||||
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {}
|
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {}
|
||||||
conf.cfgimpl_get_values().get_modified_values()
|
conf.cfgimpl_get_values().get_modified_values()
|
||||||
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {'wantref': ('user', False), 'wantref2': ('user', False)}
|
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {
|
||||||
|
'wantref': ('user', False), 'wantref2': ('user', False),
|
||||||
|
'wantref3': ('user', [False])}
|
||||||
|
|
||||||
|
|
||||||
def test_force_store_value_modified_ro():
|
def test_force_store_value_modified_ro():
|
||||||
|
@ -216,7 +219,9 @@ def test_force_store_value_modified_ro():
|
||||||
conf.read_only()
|
conf.read_only()
|
||||||
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {}
|
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {}
|
||||||
conf.cfgimpl_get_values().get_modified_values()
|
conf.cfgimpl_get_values().get_modified_values()
|
||||||
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {'wantref': ('user', False), 'wantref2': ('user', False)}
|
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {
|
||||||
|
'wantref': ('user', False), 'wantref2': ('user', False),
|
||||||
|
'wantref3': ('user', [False])}
|
||||||
|
|
||||||
|
|
||||||
def test_force_store_value_modified_hidden():
|
def test_force_store_value_modified_hidden():
|
||||||
|
@ -226,4 +231,13 @@ def test_force_store_value_modified_hidden():
|
||||||
conf.read_write()
|
conf.read_write()
|
||||||
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {}
|
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {}
|
||||||
conf.cfgimpl_get_values().get_modified_values()
|
conf.cfgimpl_get_values().get_modified_values()
|
||||||
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {'wantref': ('user', False), 'wantref2': ('user', False)}
|
assert conf.cfgimpl_get_values()._p_.get_modified_values() == {
|
||||||
|
'wantref': ('user', False), 'wantref2': ('user', False),
|
||||||
|
'wantref3': ('user', [False])}
|
||||||
|
|
||||||
|
|
||||||
|
def test_force_store_value_multi():
|
||||||
|
descr = make_description_freeze()
|
||||||
|
conf = Config(descr)
|
||||||
|
conf.read_write()
|
||||||
|
assert conf.getowner(conf.unwrap_from_path('wantref3')) == 'user'
|
||||||
|
|
|
@ -264,7 +264,11 @@ class Values(object):
|
||||||
#FIXME pas de test avec les metas ...
|
#FIXME pas de test avec les metas ...
|
||||||
#FIXME et les symlinkoption ...
|
#FIXME et les symlinkoption ...
|
||||||
if is_default and 'force_store_value' in setting[opt]:
|
if is_default and 'force_store_value' in setting[opt]:
|
||||||
self.setitem(opt, value, path, is_write=False,
|
if isinstance(value, Multi):
|
||||||
|
item = list(value)
|
||||||
|
else:
|
||||||
|
item = value
|
||||||
|
self.setitem(opt, item, path, is_write=False,
|
||||||
force_permissive=force_permissive)
|
force_permissive=force_permissive)
|
||||||
if validate_properties:
|
if validate_properties:
|
||||||
setting.validate_properties(opt, False, False, value=value,
|
setting.validate_properties(opt, False, False, value=value,
|
||||||
|
|
Loading…
Reference in New Issue