diff --git a/test/test_permissive.py b/test/test_permissive.py index f4de786..f52ed6e 100644 --- a/test/test_permissive.py +++ b/test/test_permissive.py @@ -27,6 +27,7 @@ def test_permissive(): props = err.proptype assert set(props) == {'disabled'} api.unrestraint.permissive.set(frozenset(['disabled'])) + assert api.unrestraint.permissive.get() == frozenset(['disabled']) props = frozenset() try: api.option('u1').value.get() @@ -58,6 +59,7 @@ def test_permissive_mandatory(): else: assert frozenset(props) == frozenset(['disabled']) api.unrestraint.permissive.set(frozenset(['mandatory', 'disabled'])) + assert api.unrestraint.permissive.get() == frozenset(['mandatory', 'disabled']) api.property.add('permissive') api.option('u1').value.get() api.property.pop('permissive') @@ -76,6 +78,7 @@ def test_permissive_frozen(): api = Config(descr) api.property.read_write() api.unrestraint.permissive.set(frozenset(['frozen', 'disabled'])) + assert api.unrestraint.permissive.get() == frozenset(['frozen', 'disabled']) try: api.option('u1').value.set(1) except PropertiesOptionError as err: @@ -232,6 +235,7 @@ def test_permissive_option_mandatory(): else: assert frozenset(props) == frozenset(['disabled']) api.unrestraint.option('u1').permissive.set(frozenset(['mandatory', 'disabled'])) + assert api.unrestraint.option('u1').permissive.get() == frozenset(['mandatory', 'disabled']) api.property.add('permissive') api.option('u1').value.get() api.property.pop('permissive') @@ -274,6 +278,8 @@ def test_remove_option_permissive(): api.property.read_write() raises(PropertiesOptionError, "api.option('od1.var1').value.get()") api.forcepermissive.option('od1.var1').permissive.set(frozenset(['hidden'])) + assert api.forcepermissive.option('od1.var1').permissive.get() == frozenset(['hidden']) assert api.option('od1.var1').value.get() == 'value' api.forcepermissive.option('od1.var1').permissive.set(frozenset()) + assert api.forcepermissive.option('od1.var1').permissive.get() == frozenset() raises(PropertiesOptionError, "api.option('od1.var1').value.get()") diff --git a/tiramisu/api.py b/tiramisu/api.py index 4baff11..40f5a3b 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -368,8 +368,8 @@ class TiramisuOptionPermissive(CommonTiramisuOption): def set(self, permissives): """set permissives value""" option = self.option_bag.option - self.settings.setpermissive(self.option_bag, - permissives=permissives) + self.settings.setpermissives(self.option_bag, + permissives=permissives) def reset(self): """reset all personalised permissive""" @@ -739,7 +739,7 @@ class TiramisuContextProperty(TiramisuContext): settings = self.config_bag.context.cfgimpl_get_settings() settings.read_write() # #FIXME ? - settings.set_context_permissive(frozenset(['hidden'])) + settings.set_context_permissives(frozenset(['hidden'])) try: del self.config_bag.properties except AttributeError: @@ -787,11 +787,11 @@ class TiramisuContextPermissive(TiramisuContext): def get(self): """get configuration permissives""" - return self.config_bag.context.cfgimpl_get_settings().get_context_permissive() + return self.config_bag.context.cfgimpl_get_settings().get_context_permissives() def set(self, permissives): """set configuration permissives""" - self.config_bag.context.cfgimpl_get_settings().set_context_permissive(permissives) + self.config_bag.context.cfgimpl_get_settings().set_context_permissives(permissives) def exportation(self): """export configuration permissives""" diff --git a/tiramisu/setting.py b/tiramisu/setting.py index ee2346b..093c329 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -625,14 +625,14 @@ class Settings(object): except AttributeError: pass - def set_context_permissive(self, - permissive): - self.setpermissive(None, - permissive) + def set_context_permissives(self, + permissives): + self.setpermissives(None, + permissives) - def setpermissive(self, - option_bag, - permissives): + def setpermissives(self, + option_bag, + permissives): """ enables us to put the permissives in the storage @@ -658,7 +658,7 @@ class Settings(object): if forbidden_permissives: raise ConfigError(_('cannot add those permissives: {0}').format( ' '.join(forbidden_permissives))) - self._pp_.setpermissive(path, permissives) + self._pp_.setpermissives(path, permissives) if option_bag is not None: self._getcontext().cfgimpl_reset_cache(option_bag) diff --git a/tiramisu/storage/dictionary/setting.py b/tiramisu/storage/dictionary/setting.py index c28ba33..4546187 100644 --- a/tiramisu/storage/dictionary/setting.py +++ b/tiramisu/storage/dictionary/setting.py @@ -73,14 +73,14 @@ class Permissives(Cache): self._permissives = {} super(Permissives, self).__init__(storage) - def setpermissive(self, path, permissive): + def setpermissives(self, path, permissives): if DEBUG: # pragma: no cover - print('setpermissive', path, permissive) - if not permissive: + print('setpermissives', path, permissives) + if not permissives: if path in self._permissives: del self._permissives[path] else: - self._permissives[path] = permissive + self._permissives[path] = permissives def getpermissives(self, path=None): ret = self._permissives.get(path, frozenset())