How to use the aria2p.ClientException function in aria2p

To help you get started, we’ve selected a few aria2p 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 pawamoy / aria2p / tests / test_client.py View on Github external
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
github pawamoy / aria2p / tests / test_client.py View on Github external
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
github pawamoy / aria2p / tests / test_downloads.py View on Github external
def test_move(self):
        with Aria2Server(port=7403) as server:
            self.download.api = server.api
            with pytest.raises(ClientException):
                self.download.move(2)
github pawamoy / aria2p / tests / test_downloads.py View on Github external
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()