示例#1
0
    def test_get_download_dir_error(self, qbittorrent_client):
        rpc_client = qbittorrent_client.return_value
        qbittorrent_client.side_effect = qbittorrentapi.HTTP500Error

        plugin = QBittorrentClientPlugin()

        settings = self.DEFAULT_SETTINGS
        plugin.set_settings(settings)

        with pytest.raises(qbittorrentapi.HTTP500Error) as e:
            plugin.get_download_dir()
示例#2
0
    def test_get_download_dir_success(self, qbittorrent_client):
        rpc_client = qbittorrent_client.return_value
        rpc_client.app_default_save_path.return_value = '/mnt/media/downloads'

        plugin = QBittorrentClientPlugin()

        assert plugin.get_download_dir() is None

        settings = self.DEFAULT_SETTINGS
        plugin.set_settings(settings)

        assert plugin.get_download_dir() == u'/mnt/media/downloads'

        rpc_client.app_default_save_path.assert_called_once()
    def test_get_download_dir_error(self, qbittorrent_client):
        client = qbittorrent_client.return_value
        client.app_default_save_path.side_effect = qbittorrentapi.HTTP500Error

        plugin = QBittorrentClientPlugin()

        settings = self.DEFAULT_SETTINGS
        plugin.set_settings(settings)

        self.assertIsNone(plugin.get_download_dir())
示例#4
0
    def test_get_download_dir_success(self, mocker):
        target = "{0}:{1}/".format(self.real_host, self.real_port)

        mocker.post(target + "login", text="Ok.")

        preferences = {'save_path': u'/mnt/media/downloads'}
        mocker.get(target + "query/preferences", text=json.dumps(preferences))

        plugin = QBittorrentClientPlugin()

        assert plugin.get_download_dir() is None

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

        assert plugin.get_download_dir() == u'/mnt/media/downloads'
示例#5
0
    def test_get_download_dir_error(self, mocker):
        target = "{0}:{1}/".format(self.real_host, self.real_port)

        mocker.post(target + "login", text="Ok.")

        error = {'error': 500}
        mocker.get(target + "query/preferences",
                   status_code=500,
                   text=json.dumps(error))

        settings = {
            'host': self.real_host,
            'port': self.real_port,
            'username': self.real_login,
            'password': self.real_password
        }

        plugin = QBittorrentClientPlugin()
        plugin.set_settings(settings)

        assert plugin.get_download_dir() is None