Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test(self, *_):
result = request("http://foo", "foo")
self.assertEqual(result, "bar")
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.*'),
)
def test(self, *_):
response = HTTPClient("http://test/").request("http://foo", "foo")
assert response.data.result == "bar"
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
)
def test(self, *_):
response = HTTPClient("http://test/").notify("http://foo", "foo")
assert response.data.result == "bar"
def test(self):
assert Notification("get") == {"jsonrpc": "2.0", "method": "get"}
def test_send_batch(*_):
requests = [Request("foo"), Request("bar")]
response = DummyClient().send(requests)
assert response.data.ok == True
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.*"),
)
def send_message(self, request, response_expected):
return Response('{"jsonrpc": "2.0", "result": 1, "id": 1}')
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")