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) )
def test_to_response_notification(): with pytest.raises(AssertionError): to_response(Request("ping", [], NOID), SuccessResult(result=sentinel.result))
def test_to_response_SuccessResult(): assert to_response( Request("ping", [], sentinel.id), Right(SuccessResult(sentinel.result)) ) == Right(SuccessResponse(sentinel.result, sentinel.id))
def test_to_response_InvalidParams_no_data(): assert to_response(Request("ping", [], sentinel.id), InvalidParams()) == Left( ErrorResponse(-32602, "Invalid params", NODATA, sentinel.id) )