How to use jsonrpcclient - 10 common examples

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_init.py View on Github external
def test(self, *_):
        result = request("http://foo", "foo")
        self.assertEqual(result, "bar")
github bcb / jsonrpcclient / tests / test_client.py View on Github external
def test(self):
        with LogCapture() as capture:
            DummyClient().log_response(
                Response('{"jsonrpc": "2.0", "result": 5, "id": 1}')
            )
        capture.check(
            (
                "jsonrpcclient.client.response",
                "INFO",
                StringComparison(r'.*"result": 5.*'),
            )
github bcb / jsonrpcclient / tests / clients / test_http_client.py View on Github external
def test(self, *_):
        response = HTTPClient("http://test/").request("http://foo", "foo")
        assert response.data.result == "bar"
github bcb / jsonrpcclient / tests / clients / test_http_client.py View on Github external
def test(self):
        responses.add(
            responses.POST,
            "http://foo",
            status=200,
            body='{"jsonrpc": "2.0", "result": 5, "id": 1}',
        )
        HTTPClient("http://foo").send_message(
            str(Request("foo")), response_expected=True
        )
github bcb / jsonrpcclient / tests / clients / test_http_client.py View on Github external
def test(self, *_):
        response = HTTPClient("http://test/").notify("http://foo", "foo")
        assert response.data.result == "bar"
github bcb / jsonrpcclient / tests / test_requests.py View on Github external
def test(self):
        assert Notification("get") == {"jsonrpc": "2.0", "method": "get"}
github bcb / jsonrpcclient / tests / test_client.py View on Github external
def test_send_batch(*_):
    requests = [Request("foo"), Request("bar")]
    response = DummyClient().send(requests)
    assert response.data.ok == True
github bcb / jsonrpcclient / tests / test_client.py View on Github external
def test_trimmed(self):
        req = '{"jsonrpc": "2.0", "result": "%s", "id": 1}' % ("foo" * 100,)
        with LogCapture() as capture:
            DummyClient().log_response(Response(req), trim_log_values=True)
        capture.check(
            (
                "jsonrpcclient.client.response",
                "INFO",
                StringComparison(r".*foofoofoof...ofoofoofoo.*"),
            )
github bcb / jsonrpcclient / tests / test_client.py View on Github external
def send_message(self, request, response_expected):
        return Response('{"jsonrpc": "2.0", "result": 1, "id": 1}')
github bcb / jsonrpcclient / tests / test_client.py View on Github external
def test_send_single_request_error(*_):
    with pytest.raises(ReceivedErrorResponseError):
        client = DummyClient()
        client.send_message = Mock(
            return_value=Response(
                '{"jsonrpc": "2.0", "error": {"code": 1, "message": "foo"}, "id": 1}'
            )
        )
        client.request("ping")