setpermissive => setpermissives
This commit is contained in:
parent
b381e0322f
commit
89ccfa8aa1
|
@ -27,6 +27,7 @@ def test_permissive():
|
||||||
props = err.proptype
|
props = err.proptype
|
||||||
assert set(props) == {'disabled'}
|
assert set(props) == {'disabled'}
|
||||||
api.unrestraint.permissive.set(frozenset(['disabled']))
|
api.unrestraint.permissive.set(frozenset(['disabled']))
|
||||||
|
assert api.unrestraint.permissive.get() == frozenset(['disabled'])
|
||||||
props = frozenset()
|
props = frozenset()
|
||||||
try:
|
try:
|
||||||
api.option('u1').value.get()
|
api.option('u1').value.get()
|
||||||
|
@ -58,6 +59,7 @@ def test_permissive_mandatory():
|
||||||
else:
|
else:
|
||||||
assert frozenset(props) == frozenset(['disabled'])
|
assert frozenset(props) == frozenset(['disabled'])
|
||||||
api.unrestraint.permissive.set(frozenset(['mandatory', 'disabled']))
|
api.unrestraint.permissive.set(frozenset(['mandatory', 'disabled']))
|
||||||
|
assert api.unrestraint.permissive.get() == frozenset(['mandatory', 'disabled'])
|
||||||
api.property.add('permissive')
|
api.property.add('permissive')
|
||||||
api.option('u1').value.get()
|
api.option('u1').value.get()
|
||||||
api.property.pop('permissive')
|
api.property.pop('permissive')
|
||||||
|
@ -76,6 +78,7 @@ def test_permissive_frozen():
|
||||||
api = Config(descr)
|
api = Config(descr)
|
||||||
api.property.read_write()
|
api.property.read_write()
|
||||||
api.unrestraint.permissive.set(frozenset(['frozen', 'disabled']))
|
api.unrestraint.permissive.set(frozenset(['frozen', 'disabled']))
|
||||||
|
assert api.unrestraint.permissive.get() == frozenset(['frozen', 'disabled'])
|
||||||
try:
|
try:
|
||||||
api.option('u1').value.set(1)
|
api.option('u1').value.set(1)
|
||||||
except PropertiesOptionError as err:
|
except PropertiesOptionError as err:
|
||||||
|
@ -232,6 +235,7 @@ def test_permissive_option_mandatory():
|
||||||
else:
|
else:
|
||||||
assert frozenset(props) == frozenset(['disabled'])
|
assert frozenset(props) == frozenset(['disabled'])
|
||||||
api.unrestraint.option('u1').permissive.set(frozenset(['mandatory', '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.property.add('permissive')
|
||||||
api.option('u1').value.get()
|
api.option('u1').value.get()
|
||||||
api.property.pop('permissive')
|
api.property.pop('permissive')
|
||||||
|
@ -274,6 +278,8 @@ def test_remove_option_permissive():
|
||||||
api.property.read_write()
|
api.property.read_write()
|
||||||
raises(PropertiesOptionError, "api.option('od1.var1').value.get()")
|
raises(PropertiesOptionError, "api.option('od1.var1').value.get()")
|
||||||
api.forcepermissive.option('od1.var1').permissive.set(frozenset(['hidden']))
|
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'
|
assert api.option('od1.var1').value.get() == 'value'
|
||||||
api.forcepermissive.option('od1.var1').permissive.set(frozenset())
|
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()")
|
raises(PropertiesOptionError, "api.option('od1.var1').value.get()")
|
||||||
|
|
|
@ -368,8 +368,8 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||||
def set(self, permissives):
|
def set(self, permissives):
|
||||||
"""set permissives value"""
|
"""set permissives value"""
|
||||||
option = self.option_bag.option
|
option = self.option_bag.option
|
||||||
self.settings.setpermissive(self.option_bag,
|
self.settings.setpermissives(self.option_bag,
|
||||||
permissives=permissives)
|
permissives=permissives)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""reset all personalised permissive"""
|
"""reset all personalised permissive"""
|
||||||
|
@ -739,7 +739,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||||
settings = self.config_bag.context.cfgimpl_get_settings()
|
settings = self.config_bag.context.cfgimpl_get_settings()
|
||||||
settings.read_write()
|
settings.read_write()
|
||||||
# #FIXME ?
|
# #FIXME ?
|
||||||
settings.set_context_permissive(frozenset(['hidden']))
|
settings.set_context_permissives(frozenset(['hidden']))
|
||||||
try:
|
try:
|
||||||
del self.config_bag.properties
|
del self.config_bag.properties
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -787,11 +787,11 @@ class TiramisuContextPermissive(TiramisuContext):
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
"""get configuration permissives"""
|
"""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):
|
def set(self, permissives):
|
||||||
"""set configuration 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):
|
def exportation(self):
|
||||||
"""export configuration permissives"""
|
"""export configuration permissives"""
|
||||||
|
|
|
@ -625,14 +625,14 @@ class Settings(object):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_context_permissive(self,
|
def set_context_permissives(self,
|
||||||
permissive):
|
permissives):
|
||||||
self.setpermissive(None,
|
self.setpermissives(None,
|
||||||
permissive)
|
permissives)
|
||||||
|
|
||||||
def setpermissive(self,
|
def setpermissives(self,
|
||||||
option_bag,
|
option_bag,
|
||||||
permissives):
|
permissives):
|
||||||
"""
|
"""
|
||||||
enables us to put the permissives in the storage
|
enables us to put the permissives in the storage
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ class Settings(object):
|
||||||
if forbidden_permissives:
|
if forbidden_permissives:
|
||||||
raise ConfigError(_('cannot add those permissives: {0}').format(
|
raise ConfigError(_('cannot add those permissives: {0}').format(
|
||||||
' '.join(forbidden_permissives)))
|
' '.join(forbidden_permissives)))
|
||||||
self._pp_.setpermissive(path, permissives)
|
self._pp_.setpermissives(path, permissives)
|
||||||
if option_bag is not None:
|
if option_bag is not None:
|
||||||
self._getcontext().cfgimpl_reset_cache(option_bag)
|
self._getcontext().cfgimpl_reset_cache(option_bag)
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,14 @@ class Permissives(Cache):
|
||||||
self._permissives = {}
|
self._permissives = {}
|
||||||
super(Permissives, self).__init__(storage)
|
super(Permissives, self).__init__(storage)
|
||||||
|
|
||||||
def setpermissive(self, path, permissive):
|
def setpermissives(self, path, permissives):
|
||||||
if DEBUG: # pragma: no cover
|
if DEBUG: # pragma: no cover
|
||||||
print('setpermissive', path, permissive)
|
print('setpermissives', path, permissives)
|
||||||
if not permissive:
|
if not permissives:
|
||||||
if path in self._permissives:
|
if path in self._permissives:
|
||||||
del self._permissives[path]
|
del self._permissives[path]
|
||||||
else:
|
else:
|
||||||
self._permissives[path] = permissive
|
self._permissives[path] = permissives
|
||||||
|
|
||||||
def getpermissives(self, path=None):
|
def getpermissives(self, path=None):
|
||||||
ret = self._permissives.get(path, frozenset())
|
ret = self._permissives.get(path, frozenset())
|
||||||
|
|
Loading…
Reference in New Issue