This commit is contained in:
Emmanuel Garette 2018-09-29 21:58:41 +02:00
parent 69da6ed5e6
commit 509d902e72
7 changed files with 20 additions and 28 deletions

View File

@ -154,7 +154,7 @@ class ConstError(TypeError):
#Warning
class ValueWarning(UserWarning): # pragma: optional cover
class ValueWarning(UserWarning):
"""Option could warn user and not raise ValueError.
Example:

View File

@ -52,13 +52,13 @@ class MasterSlaves(OptionDescription):
raise ValueError(_('a master and a slave are mandatories in masterslaves "{}"').format(name))
master = children[0]
for idx, child in enumerate(children):
if child.impl_is_symlinkoption(): # pragma: optional cover
if child.impl_is_symlinkoption():
raise ValueError(_('masterslaves "{0}" shall not have '
"a symlinkoption").format(self.impl_get_display_name()))
if not isinstance(child, Option): # pragma: optional cover
if not isinstance(child, Option):
raise ValueError(_('masterslaves "{0}" shall not have '
'a subgroup').format(self.impl_get_display_name()))
if not child.impl_is_multi(): # pragma: optional cover
if not child.impl_is_multi():
raise ValueError(_('only multi option allowed in masterslaves "{0}" but option '
'"{1}" is not a multi').format(self.impl_get_display_name(),
child.impl_get_display_name()))

View File

@ -164,11 +164,6 @@ class Option(OnlyOption):
def impl_is_multi(self):
return getattr(self, '_multi', 1) != 1
def _validate(self,
*args,
**kwargs): # pragma: no cover
pass
def impl_is_unique(self):
return getattr(self, '_unique', False)
@ -237,7 +232,7 @@ class Option(OnlyOption):
def do_validation(_value,
_index):
if isinstance(_value, list): # pragma: no cover
if isinstance(_value, list):
raise ValueError(_('which must not be a list').format(_value,
self.impl_get_display_name()))
if _value is not None:
@ -477,10 +472,8 @@ class Option(OnlyOption):
for opt in other_opts:
if isinstance(opt, weakref.ReferenceType):
opt = opt()
if opt.impl_is_submulti(): # pragma: no cover
raise ConfigError(_('cannot add consistency with submulti option'))
if not isinstance(opt, Option): # pragma: no cover
raise ConfigError(_('consistency must be set with an option, not {}').format(opt))
assert not opt.impl_is_submulti(), _('cannot add consistency with submulti option')
assert isinstance(opt, Option), _('consistency must be set with an option, not {}').format(opt)
if opt.issubdyn():
if dynod is None:
raise ConfigError(_('almost one option in consistency is '

View File

@ -568,7 +568,7 @@ class Settings(object):
else:
if operator == 'and':
calc_properties.add(action)
continue # pragma: no cover
continue
if breaked:
break
return calc_properties
@ -666,9 +666,8 @@ class Settings(object):
opt = None
else:
opt = option_bag.option
if all_properties and option_bag: # pragma: no cover
raise ValueError(_('opt and all_properties must not be set '
'together in reset'))
assert all_properties is False or option_bag is None, _('opt and all_properties must not be'
' set together in reset')
if opt and opt.impl_is_symlinkoption():
raise TypeError(_("can't reset properties to the symlinkoption \"{}\""
"").format(opt.impl_get_display_name()))

View File

@ -47,7 +47,7 @@ class StorageType(object):
storage_type = None
mod = None
def set(self, name): # pragma: optional cover
def set(self, name):
if self.storage_type is not None: # pragma: no cover
if self.storage_type == name:
return
@ -115,7 +115,7 @@ def get_default_settings_storages():
return properties, permissives
def list_sessions(type_): # pragma: optional cover
def list_sessions(type_):
"""List all available session (persistent or not persistent)
"""
#if type_ == 'option':
@ -124,7 +124,7 @@ def list_sessions(type_): # pragma: optional cover
return storage_type.get().list_sessions()
def delete_session(session_id): # pragma: optional cover
def delete_session(session_id):
"""Delete a selected session, be careful, you can deleted a session
use by an other instance
:params session_id: id of session to delete

View File

@ -28,7 +28,7 @@ setting = Setting()
_list_sessions = []
def list_sessions(): # pragma: optional cover
def list_sessions():
return _list_sessions
@ -39,9 +39,9 @@ class Storage(object):
serializable = True
def __init__(self, session_id, persistent, test=False):
if not test and session_id in _list_sessions: # pragma: optional cover
if not test and session_id in _list_sessions:
raise ConflictError(_('session "{}" already used').format(session_id))
if persistent: # pragma: optional cover
if persistent:
raise ValueError(_('a dictionary cannot be persistent'))
self.session_id = session_id
self.persistent = persistent
@ -50,7 +50,7 @@ class Storage(object):
def __del__(self):
try:
_list_sessions.remove(self.session_id)
except AttributeError: # pragma: optional cover
except AttributeError:
pass

View File

@ -41,7 +41,7 @@ class Session(SqlAlchemyBase):
self.session = session_id
def list_sessions(): # pragma: optional cover
def list_sessions():
session = util.Session()
ret = []
for val in session.query(Session).all():
@ -50,7 +50,7 @@ def list_sessions(): # pragma: optional cover
return ret
def delete_session(session_id, session): # pragma: optional cover
def delete_session(session_id, session):
session.delete(session.query(Session).filter_by(session=session_id).first())
session.commit()
@ -69,7 +69,7 @@ class Storage(object):
session = getsession()
self.session_id = session_id
self.persistent = persistent
if not session.query(Session).filter_by(session=session_id).first(): # pragma: optional cover
if not session.query(Session).filter_by(session=session_id).first():
session.add(Session(session_id))
session.commit()
del(session)