示例#1
0
    def test_add_torrent_with_settings_success(self, qbittorrent_client):
        rpc_client = qbittorrent_client.return_value
        rpc_client.torrents_add.return_value = 'Ok.'

        plugin = QBittorrentClientPlugin()
        settings = self.DEFAULT_SETTINGS
        plugin.set_settings(settings)

        torrent = b'torrent'
        self.assertEqual('Ok.', plugin.add_torrent(torrent, TopicSettings("/path/to/download")))
示例#2
0
    def test_add_torrent_with_settings(self, deluge_client):
        rpc_client = deluge_client.return_value
        rpc_client.connected = True

        plugin = DelugeClientPlugin()
        settings = {'host': 'localhost', 'username': '******', 'password': '******'}
        plugin.set_settings(settings)

        rpc_client.call.return_value = True

        torrent = b'!torrent.content'
        self.assertTrue(plugin.add_torrent(torrent, TopicSettings('/path/to/download')))

        options = {
            'download_location': '/path/to/download'
        }

        rpc_client.call.assert_called_once_with('core.add_torrent_file', None, base64.b64encode(torrent), options)
    def test_add_torrent_with_settings(self, transmission_client):
        rpc_client = transmission_client.return_value

        plugin = TransmissionClientPlugin()
        settings = {
            'host': 'localhost',
            'username': '******',
            'password': '******'
        }
        plugin.set_settings(settings)

        torrent = b'!torrent.content'
        self.assertTrue(
            plugin.add_torrent(torrent,
                               TopicSettings('/path/to/download/dir')))

        rpc_client.add_torrent.assert_called_once_with(
            base64.b64encode(torrent).decode('utf-8'),
            download_dir='/path/to/download/dir')
示例#4
0
    def test_add_torrent_with_settings_success(self, post_mock):
        response = Response()
        response._content = b"Ok."
        response.status_code = 200
        good_response = Response()
        good_response.status_code = 200
        post_mock.side_effect = [response, good_response]

        plugin = QBittorrentClientPlugin()
        settings = {
            'host': self.real_host,
            'port': self.real_port,
            'username': self.real_login,
            'password': self.real_password
        }
        plugin.set_settings(settings)

        torrent = b'torrent'
        self.assertTrue(
            plugin.add_torrent(torrent, TopicSettings("/path/to/download")))