def test_serverautherror_str(self, msg, details):
        """All tests for ServerAuthError.__str__()."""

        exc = ServerAuthError(msg, details)

        exp_str = str(exc.args[0])

        # Execute the code to be tested
        str_str = str(exc)

        assert str_str == exp_str
예제 #2
0
def test_serverautherror_str_def(msg, details):
    """All tests for ServerAuthError.str_def()."""

    exc = ServerAuthError(msg, details)

    classname = exc.__class__.__name__
    request_method = details.request_method
    request_uri = details.request_uri
    http_status = details.http_status
    reason = details.reason

    # Execute the code to be tested
    str_def = exc.str_def()

    str_def = ' ' + str_def
    assert str_def.find(' classname={!r};'.format(classname)) >= 0
    assert str_def.find(' request_method={!r};'.format(request_method)) >= 0
    assert str_def.find(' request_uri={!r};'.format(request_uri)) >= 0
    assert str_def.find(' http_status={!r};'.format(http_status)) >= 0
    assert str_def.find(' reason={!r};'.format(reason)) >= 0
    assert str_def.find(' message={!r};'.format(msg)) >= 0
    def test_serverautherror_repr(self, msg, details):
        """All tests for ServerAuthError.__repr__()."""

        exc = ServerAuthError(msg, details)

        classname = exc.__class__.__name__

        # Execute the code to be tested
        repr_str = repr(exc)

        # We check the one-lined string just roughly
        repr_str = repr_str.replace('\n', '\\n')
        assert re.match(r'^{}\s*\(.*\)$'.format(classname), repr_str)
    def test_serverautherror_initial_attrs(self, arg_names, args):
        """Test initial attributes of ServerAuthError."""

        msg, details = args
        posargs, kwargs = func_args(args, arg_names)

        # Execute the code to be tested
        exc = ServerAuthError(*posargs, **kwargs)

        assert isinstance(exc, AuthError)
        assert len(exc.args) == 1
        assert exc.args[0] == msg
        assert exc.details == details