def test_client_add_kwargs(): m = mock.Mock(return_value={"hello": "workd"}) with mock.patch("transmission_rpc.client.Client._request", m): c = Client() c.protocol_version = 15 c.add_torrent( torrent_url, download_dir="dd", files_unwanted=[1, 2], files_wanted=[3, 4], paused=False, peer_limit=5, priority_high=[6], priority_low=[7], priority_normal=[8], cookies="coo", bandwidthPriority=4, ) m.assert_called_with( "torrent-add", { "filename": torrent_url, "download-dir": "dd", "files-unwanted": [1, 2], "files-wanted": [3, 4], "paused": False, "peer-limit": 5, "priority-high": [6], "priority-low": [7], "priority-normal": [8], "cookies": "coo", "bandwidthPriority": 4, }, timeout=None, )
def test_check_rpc_version_for_args(): m = mock.Mock(return_value={"hello": "world"}) with mock.patch("transmission_rpc.client.Client._request", m): c = Client() c.protocol_version = 7 with pytest.raises(ValueError): c.add_torrent(magnet_url, cookies="")
def test_check_rpc_version_for_args(): m = mock.Mock(return_value={"hello": "world"}) with mock.patch("transmission_rpc.client.Client._request", m): c = Client() c.protocol_version = 7 with pytest.raises( TransmissionVersionError, match='Method "torrent-add" Argument "cookies" does not exist in version 7', ): c.add_torrent(magnet_url, cookies="")