Example #1
0
def test_to_response_ErrorResult():
    assert (
        to_response(
            Request("ping", [], sentinel.id),
            Left(
                ErrorResult(
                    code=sentinel.code, message=sentinel.message, data=sentinel.data
                )
            ),
        )
    ) == Left(
        ErrorResponse(sentinel.code, sentinel.message, sentinel.data, sentinel.id)
    )
Example #2
0
def test_to_response_notification():
    with pytest.raises(AssertionError):
        to_response(Request("ping", [], NOID), SuccessResult(result=sentinel.result))
Example #3
0
def test_to_response_SuccessResult():
    assert to_response(
        Request("ping", [], sentinel.id), Right(SuccessResult(sentinel.result))
    ) == Right(SuccessResponse(sentinel.result, sentinel.id))
Example #4
0
def test_to_response_InvalidParams_no_data():
    assert to_response(Request("ping", [], sentinel.id), InvalidParams()) == Left(
        ErrorResponse(-32602, "Invalid params", NODATA, sentinel.id)
    )