def test_load_torrents_still_downloading(self): def _is_torrent_downloading(media_items): return True self.patch(loader, '_is_torrent_downloading', _is_torrent_downloading) loader.load_torrents(self.dbapi)
def test_load_torrents_no_parse(self): for tor in glob.glob(os.path.join(torrent_path, '*.torrent')): _tor = models.Torrent.make_empty() _tor.name = os.path.basename(tor) _tor.invalid = True self.dbapi.save_torrent(_tor) loader.load_torrents(self.dbapi)
def test_load_torrents_parse_error(self): class TorrentParser(object): def __init__(self, tfile): raise parser.ParsingError('failed to parse') self.patch(parser, 'TorrentParser', TorrentParser) loader.load_torrents(self.dbapi)
def _get_work(dbapi): # search through the directory of torrents and load any # new ones into the cache. loader.load_torrents(dbapi) flows = [] # now retrieve any torrents that are eligible for processing # and kick off the workflows. for tor in dbapi.get_torrents_active(): # need to make sure there are actually media files that # were parsed for the torrent. LOG.debug("torrent %s media files: %s", tor.torrent_id, tor.media_files) if tor.media_files: LOG.debug("creating workflow for torrent: %s", tor) flows.append(workflow.Workflow(dbapi, tor)) return flows
def test_load_torrents(self): loader.load_torrents(self.dbapi)