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_call_raises_custom_error(self):
client = Client()
responses.add(
responses.POST, client.server, json={"error": {"code": 1, "message": "Custom message"}}, status=200
)
with pytest.raises(ClientException, match=r"Custom message") as e:
client.call("aria2.method")
assert e.code == 1
def test_call_raises_known_error(self):
client = Client()
responses.add(
responses.POST,
client.server,
json={"error": {"code": JSONRPC_PARSER_ERROR, "message": "Custom message"}},
status=200,
)
with pytest.raises(ClientException, match=rf"{JSONRPC_CODES[JSONRPC_PARSER_ERROR]}\nCustom message") as e:
client.call("aria2.method")
assert e.code == JSONRPC_PARSER_ERROR
def test_move(self):
with Aria2Server(port=7403) as server:
self.download.api = server.api
with pytest.raises(ClientException):
self.download.move(2)
def test_move_to_bottom(self):
with Aria2Server(port=7406) as server:
self.download.api = server.api
with pytest.raises(ClientException):
self.download.move_to_bottom()