How to use the jsonrpcclient.parse.parse function in jsonrpcclient

To help you get started, we’ve selected a few jsonrpcclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bcb / jsonrpcclient / tests / test_parse.py View on Github external
def test_parse_invalid_jsonrpc():
    with pytest.raises(ValidationError):
        parse('{"json": "2.0"}', batch=False)
github bcb / jsonrpcclient / tests / test_parse.py View on Github external
def test_parse_empty_string_single():
    assert parse("", batch=False).result is None
github bcb / jsonrpcclient / tests / test_parse.py View on Github external
def test_parse_none_single():
    assert parse(None, batch=False).result is None
github bcb / jsonrpcclient / tests / test_parse.py View on Github external
def test_parse_without_validation():
    parse(
        '{"jsonrpc": "2.0", "result": "foo", "id": 1}',
        batch=False,
        validate_against_schema=False,
    )
github bcb / jsonrpcclient / tests / test_parse.py View on Github external
def test_parse_empty_string_batch():
    assert parse("", batch=True) == []
github bcb / jsonrpcclient / jsonrpcclient / client.py View on Github external
# We need both the serialized and deserialized version of the request
        if isinstance(request, str):
            request_text = request
            request_deserialized = deserialize(request)
        else:
            request_text = serialize(request)
            request_deserialized = request
        batch = isinstance(request_deserialized, list)
        response_expected = batch or "id" in request_deserialized
        self.log_request(request_text, trim_log_values=trim_log_values)
        response = self.send_message(
            request_text, response_expected=response_expected, **kwargs
        )
        self.log_response(response, trim_log_values=trim_log_values)
        self.validate_response(response)
        response.data = parse(
            response.text, batch=batch, validate_against_schema=validate_against_schema
        )
        # If received a single error response, raise
        if isinstance(response.data, ErrorResponse):
            raise ReceivedErrorResponseError(response.data)
        return response
github bcb / jsonrpcclient / jsonrpcclient / async_client.py View on Github external
# We need both the serialized and deserialized version of the request
        if isinstance(request, str):
            request_text = request
            request_deserialized = deserialize(request)
        else:
            request_text = serialize(request)
            request_deserialized = request
        batch = isinstance(request_deserialized, list)
        response_expected = batch or "id" in request_deserialized
        self.log_request(request_text, trim_log_values=trim_log_values)
        response = await self.send_message(
            request_text, response_expected=response_expected, **kwargs
        )
        self.log_response(response, trim_log_values=trim_log_values)
        self.validate_response(response)
        response.data = parse(
            response.text, batch=batch, validate_against_schema=validate_against_schema
        )
        # If received a single error response, raise
        if isinstance(response.data, ErrorResponse):
            raise ReceivedErrorResponseError(response.data)
        return response