force_store_value works now with permissive
authorEmmanuel Garette <egarette@cadoles.com>
Fri, 28 Mar 2014 16:35:27 +0000 (17:35 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Fri, 28 Mar 2014 16:36:02 +0000 (17:36 +0100)
test/test_freeze.py
tiramisu/value.py

index cda1406..f279c47 100644 (file)
@@ -22,13 +22,14 @@ def make_description_freeze():
     boolop = BoolOption('boolop', 'Test boolean option op', default=[True], multi=True)
     wantref_option = BoolOption('wantref', 'Test requires', default=False, properties=('force_store_value',),
                                 requires=({'option': booloption, 'expected': True, 'action': 'hidden'},))
+    wantref2_option = BoolOption('wantref2', 'Test requires', default=False, properties=('force_store_value', 'hidden'))
     wantframework_option = BoolOption('wantframework', 'Test requires',
                                       default=False,
                                       requires=({'option': booloption, 'expected': True, 'action': 'hidden'},))
 
     gcgroup = OptionDescription('gc', '', [gcoption, gcdummy, floatoption])
     descr = OptionDescription('tiramisu', '', [gcgroup, booloption, objspaceoption,
-                              wantref_option, stroption,
+                              wantref_option, wantref2_option, stroption,
                               wantframework_option,
                               intoption, boolop])
     return descr
@@ -153,3 +154,13 @@ def test_force_store_value_ro():
     assert conf.getowner(conf.unwrap_from_path('wantref')) == 'default'
     conf.wantref
     assert conf.getowner(conf.unwrap_from_path('wantref')) == 'user'
+
+
+def test_force_store_value_hidden():
+    descr = make_description_freeze()
+    conf = Config(descr)
+    conf.cfgimpl_get_settings().setpermissive(('hidden',))
+    conf.read_write()
+    assert conf.getowner(conf.unwrap_from_path('wantref2')) == 'default'
+    conf._getattr('wantref2', force_permissive=True)
+    assert conf.getowner(conf.unwrap_from_path('wantref2')) == 'user'
index 968f0e4..d66f85d 100644 (file)
@@ -243,7 +243,8 @@ class Values(object):
             opt.impl_validate(value, context, 'validator' in setting)
         if config_error is None and self._is_default_owner(path) and \
                 'force_store_value' in setting[opt]:
-            self.setitem(opt, value, path, is_write=False)
+            self.setitem(opt, value, path, is_write=False,
+                         force_permissive=force_permissive)
         if validate_properties:
             setting.validate_properties(opt, False, False, value=value, path=path,
                                         force_permissive=force_permissive,