def test_add_torrent_with_subscription_data(self):
        handler = TorrentHandler(self.log)
        subscription_data = yarss2.yarss_config.get_fresh_subscription_config()
        subscription_data["move_completed"] = "move/path"
        subscription_data["download_location"] = "download/path"
        subscription_data[
            "add_torrents_in_paused_state"] = GeneralSubsConf.DEFAULT

        download = TorrentDownload()
        torrent_info = {
            "link": "http://url.com/file.torrent",
            "site_cookies_dict": {},
            "subscription_data": subscription_data,
            "torrent_download": download
        }

        d = handler.add_torrent(torrent_info)
        self.assertTrue(d.success)
        added = test_component.added.pop()
        self.assertTrue(added.options["move_completed"])
        self.assertEquals(added.options["move_completed_path"],
                          subscription_data["move_completed"])
        self.assertEquals(added.options["download_location"],
                          subscription_data["download_location"])
        # When using DEFAULT, the default value for add_paused on TorrentSettings is False
        self.assertEquals(added.options["add_paused"], False)
 def download_torrent_file(self, torrent_url, cookies=None, headers=None):
     download = TorrentDownload()
     download.torrent_url = torrent_url
     download.cookies = cookies
     download.headers = headers
     download.torrent_url = torrent_url
     download.success = self.download_success
     if self.use_filedump:
         download.filedump = self.use_filedump
     elif os.path.isfile(torrent_url):
         download.filedump = read_file(torrent_url)
     self.downloads.append(download)
     return download
 def add(self, filedump=None, filename=None, options=None, magnet=None):
     download = TorrentDownload()
     download.torrent_id = ""
     download.filedump = filedump
     download.filename = filename
     download.options = options
     download.magnet = magnet
     download.add_success = self.add_success
     self.added.append(download)
     return download
 def add(self, filedump=None, filename=None, options=None, magnet=None):
     download = TorrentDownload()
     download.torrent_id = ""
     download.filedump = filedump
     download.filename = filename
     download.options = options
     download.magnet = magnet
     download.add_success = self.add_success
     self.added.append(download)
     return download
 def download_torrent_file(self, torrent_url, cookies_dict):
     download = TorrentDownload()
     download.torrent_url = torrent_url
     download.cookies_dict = cookies_dict
     download.torrent_url = torrent_url
     download.success = self.download_success
     if self.use_filedump:
         download.filedump = self.use_filedump
     elif os.path.isfile(torrent_url):
         download.filedump = read_file(torrent_url)
     self.downloads.append(download)
     return download
Exemple #6
0
    def test_add_torrent(self):
        torrent_name = "FreeBSD-9.0-RELEASE-amd64-dvd1.torrent"
        torrent_url = yarss2.util.common.get_resource(torrent_name,
                                                      path="tests/data/")
        torrent_info = {"link": torrent_url}
        download_dict = self.core.add_torrent(torrent_info)
        download = TorrentDownload(download_dict)

        self.assertTrue(download.success,
                        "Download failed, but should be True")
        self.assertEquals(
            torrent_url,
            test_torrent_handling.test_component.downloads.pop().torrent_url)
        self.assertEquals(
            test_torrent_handling.test_component.added.pop().filename,
            torrent_name)