示例#1
0
def test_prewikka_user_error():
    """
    Test `prewikka.error.PrewikkaUserError` error.
    """
    # default
    error = PrewikkaUserError()

    with pytest.raises(PrewikkaUserError):
        raise error

    assert not str(error)

    # name
    error = PrewikkaUserError(name='NAME')

    with pytest.raises(PrewikkaUserError):
        raise error

    assert not str(error)  # message is required

    # message
    error = PrewikkaUserError(message='A message')

    with pytest.raises(PrewikkaUserError):
        raise error

    assert str(error)

    # name + message
    error = PrewikkaUserError(name='NAME', message='A message')

    with pytest.raises(PrewikkaUserError):
        raise error

    assert str(error)
示例#2
0
 def __init__(self,
              session,
              message=N_("Authentication failed"),
              log_priority=log.ERROR,
              log_user=None):
     PrewikkaUserError.__init__(self,
                                None,
                                message,
                                log_priority=log_priority,
                                log_user=log_user,
                                template=session.template)
示例#3
0
 def __init__(self, login=None, **kwargs):
     PrewikkaUserError.__init__(self, log_user=login, **kwargs)
示例#4
0
    def __init__(self, login=None, message=None, **kwargs):
        if message is None:
            message = _(self._default_message)

        PrewikkaUserError.__init__(self, None, message, log_user=login, **kwargs)
示例#5
0
 def __init__(self, session, message=N_("Authentication failed"), log_priority=log.ERROR, log_user=None):
     PrewikkaUserError.__init__(self, None, message, log_priority=log_priority, log_user=log_user, template=session.template)
示例#6
0
    def __init__(self, login, arguments={}, message=None, template=None):
        if message is None:
           message = _("Session expired")

        PrewikkaUserError.__init__(self, None, message, log_priority=log.ERROR, log_user=login, template=template)
示例#7
0
    def __init__(self, arguments={}, message=None, login=None, log_priority=None, template=None):
        if message is None:
            message = _("Invalid session")

        PrewikkaUserError.__init__(self, None, message, log_priority=log_priority, log_user=login, template=template)