Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
0
 def __init__(self, login=None, **kwargs):
     PrewikkaUserError.__init__(self, log_user=login, **kwargs)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)