coverage
This commit is contained in:
parent
69da6ed5e6
commit
509d902e72
|
@ -154,7 +154,7 @@ class ConstError(TypeError):
|
||||||
|
|
||||||
|
|
||||||
#Warning
|
#Warning
|
||||||
class ValueWarning(UserWarning): # pragma: optional cover
|
class ValueWarning(UserWarning):
|
||||||
"""Option could warn user and not raise ValueError.
|
"""Option could warn user and not raise ValueError.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
|
@ -52,13 +52,13 @@ class MasterSlaves(OptionDescription):
|
||||||
raise ValueError(_('a master and a slave are mandatories in masterslaves "{}"').format(name))
|
raise ValueError(_('a master and a slave are mandatories in masterslaves "{}"').format(name))
|
||||||
master = children[0]
|
master = children[0]
|
||||||
for idx, child in enumerate(children):
|
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 '
|
raise ValueError(_('masterslaves "{0}" shall not have '
|
||||||
"a symlinkoption").format(self.impl_get_display_name()))
|
"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 '
|
raise ValueError(_('masterslaves "{0}" shall not have '
|
||||||
'a subgroup').format(self.impl_get_display_name()))
|
'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 '
|
raise ValueError(_('only multi option allowed in masterslaves "{0}" but option '
|
||||||
'"{1}" is not a multi').format(self.impl_get_display_name(),
|
'"{1}" is not a multi').format(self.impl_get_display_name(),
|
||||||
child.impl_get_display_name()))
|
child.impl_get_display_name()))
|
||||||
|
|
|
@ -164,11 +164,6 @@ class Option(OnlyOption):
|
||||||
def impl_is_multi(self):
|
def impl_is_multi(self):
|
||||||
return getattr(self, '_multi', 1) != 1
|
return getattr(self, '_multi', 1) != 1
|
||||||
|
|
||||||
def _validate(self,
|
|
||||||
*args,
|
|
||||||
**kwargs): # pragma: no cover
|
|
||||||
pass
|
|
||||||
|
|
||||||
def impl_is_unique(self):
|
def impl_is_unique(self):
|
||||||
return getattr(self, '_unique', False)
|
return getattr(self, '_unique', False)
|
||||||
|
|
||||||
|
@ -237,7 +232,7 @@ class Option(OnlyOption):
|
||||||
|
|
||||||
def do_validation(_value,
|
def do_validation(_value,
|
||||||
_index):
|
_index):
|
||||||
if isinstance(_value, list): # pragma: no cover
|
if isinstance(_value, list):
|
||||||
raise ValueError(_('which must not be a list').format(_value,
|
raise ValueError(_('which must not be a list').format(_value,
|
||||||
self.impl_get_display_name()))
|
self.impl_get_display_name()))
|
||||||
if _value is not None:
|
if _value is not None:
|
||||||
|
@ -477,10 +472,8 @@ class Option(OnlyOption):
|
||||||
for opt in other_opts:
|
for opt in other_opts:
|
||||||
if isinstance(opt, weakref.ReferenceType):
|
if isinstance(opt, weakref.ReferenceType):
|
||||||
opt = opt()
|
opt = opt()
|
||||||
if opt.impl_is_submulti(): # pragma: no cover
|
assert not opt.impl_is_submulti(), _('cannot add consistency with submulti option')
|
||||||
raise ConfigError(_('cannot add consistency with submulti option'))
|
assert isinstance(opt, Option), _('consistency must be set with an option, not {}').format(opt)
|
||||||
if not isinstance(opt, Option): # pragma: no cover
|
|
||||||
raise ConfigError(_('consistency must be set with an option, not {}').format(opt))
|
|
||||||
if opt.issubdyn():
|
if opt.issubdyn():
|
||||||
if dynod is None:
|
if dynod is None:
|
||||||
raise ConfigError(_('almost one option in consistency is '
|
raise ConfigError(_('almost one option in consistency is '
|
||||||
|
|
|
@ -568,7 +568,7 @@ class Settings(object):
|
||||||
else:
|
else:
|
||||||
if operator == 'and':
|
if operator == 'and':
|
||||||
calc_properties.add(action)
|
calc_properties.add(action)
|
||||||
continue # pragma: no cover
|
continue
|
||||||
if breaked:
|
if breaked:
|
||||||
break
|
break
|
||||||
return calc_properties
|
return calc_properties
|
||||||
|
@ -666,9 +666,8 @@ class Settings(object):
|
||||||
opt = None
|
opt = None
|
||||||
else:
|
else:
|
||||||
opt = option_bag.option
|
opt = option_bag.option
|
||||||
if all_properties and option_bag: # pragma: no cover
|
assert all_properties is False or option_bag is None, _('opt and all_properties must not be'
|
||||||
raise ValueError(_('opt and all_properties must not be set '
|
' set together in reset')
|
||||||
'together in reset'))
|
|
||||||
if opt and opt.impl_is_symlinkoption():
|
if opt and opt.impl_is_symlinkoption():
|
||||||
raise TypeError(_("can't reset properties to the symlinkoption \"{}\""
|
raise TypeError(_("can't reset properties to the symlinkoption \"{}\""
|
||||||
"").format(opt.impl_get_display_name()))
|
"").format(opt.impl_get_display_name()))
|
||||||
|
|
|
@ -47,7 +47,7 @@ class StorageType(object):
|
||||||
storage_type = None
|
storage_type = None
|
||||||
mod = 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 is not None: # pragma: no cover
|
||||||
if self.storage_type == name:
|
if self.storage_type == name:
|
||||||
return
|
return
|
||||||
|
@ -115,7 +115,7 @@ def get_default_settings_storages():
|
||||||
return properties, permissives
|
return properties, permissives
|
||||||
|
|
||||||
|
|
||||||
def list_sessions(type_): # pragma: optional cover
|
def list_sessions(type_):
|
||||||
"""List all available session (persistent or not persistent)
|
"""List all available session (persistent or not persistent)
|
||||||
"""
|
"""
|
||||||
#if type_ == 'option':
|
#if type_ == 'option':
|
||||||
|
@ -124,7 +124,7 @@ def list_sessions(type_): # pragma: optional cover
|
||||||
return storage_type.get().list_sessions()
|
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
|
"""Delete a selected session, be careful, you can deleted a session
|
||||||
use by an other instance
|
use by an other instance
|
||||||
:params session_id: id of session to delete
|
:params session_id: id of session to delete
|
||||||
|
|
|
@ -28,7 +28,7 @@ setting = Setting()
|
||||||
_list_sessions = []
|
_list_sessions = []
|
||||||
|
|
||||||
|
|
||||||
def list_sessions(): # pragma: optional cover
|
def list_sessions():
|
||||||
return _list_sessions
|
return _list_sessions
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,9 +39,9 @@ class Storage(object):
|
||||||
serializable = True
|
serializable = True
|
||||||
|
|
||||||
def __init__(self, session_id, persistent, test=False):
|
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))
|
raise ConflictError(_('session "{}" already used').format(session_id))
|
||||||
if persistent: # pragma: optional cover
|
if persistent:
|
||||||
raise ValueError(_('a dictionary cannot be persistent'))
|
raise ValueError(_('a dictionary cannot be persistent'))
|
||||||
self.session_id = session_id
|
self.session_id = session_id
|
||||||
self.persistent = persistent
|
self.persistent = persistent
|
||||||
|
@ -50,7 +50,7 @@ class Storage(object):
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
try:
|
try:
|
||||||
_list_sessions.remove(self.session_id)
|
_list_sessions.remove(self.session_id)
|
||||||
except AttributeError: # pragma: optional cover
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Session(SqlAlchemyBase):
|
||||||
self.session = session_id
|
self.session = session_id
|
||||||
|
|
||||||
|
|
||||||
def list_sessions(): # pragma: optional cover
|
def list_sessions():
|
||||||
session = util.Session()
|
session = util.Session()
|
||||||
ret = []
|
ret = []
|
||||||
for val in session.query(Session).all():
|
for val in session.query(Session).all():
|
||||||
|
@ -50,7 +50,7 @@ def list_sessions(): # pragma: optional cover
|
||||||
return ret
|
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.delete(session.query(Session).filter_by(session=session_id).first())
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class Storage(object):
|
||||||
session = getsession()
|
session = getsession()
|
||||||
self.session_id = session_id
|
self.session_id = session_id
|
||||||
self.persistent = persistent
|
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.add(Session(session_id))
|
||||||
session.commit()
|
session.commit()
|
||||||
del(session)
|
del(session)
|
||||||
|
|
Loading…
Reference in New Issue