setpermissive => setpermissives
This commit is contained in:
parent
b381e0322f
commit
89ccfa8aa1
|
@ -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()")
|
||||
|
|
|
@ -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"""
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue