本文整理汇总了Python中Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler.getRandomlyCollectedTorrents方法的典型用法代码示例。如果您正苦于以下问题:Python TorrentDBHandler.getRandomlyCollectedTorrents方法的具体用法?Python TorrentDBHandler.getRandomlyCollectedTorrents怎么用?Python TorrentDBHandler.getRandomlyCollectedTorrents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler
的用法示例。
在下文中一共展示了TorrentDBHandler.getRandomlyCollectedTorrents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTorrentDBHandler
# 需要导入模块: from Tribler.Core.CacheDB.SqliteCacheDBHandler import TorrentDBHandler [as 别名]
# 或者: from Tribler.Core.CacheDB.SqliteCacheDBHandler.TorrentDBHandler import getRandomlyCollectedTorrents [as 别名]
#.........这里部分代码省略.........
['http://localhost/announce'], 1234)
self.assertTrue(self.tdb.getTorrentID(infohash))
def test_add_external_torrent_no_def_more_files(self):
infohash = unhexlify('50865489ac16e2f34ea0cd3043cfd970cc24ec09')
self.tdb.addExternalTorrentNoDef(infohash, "test torrent", [("file1", 42), ("file2", 43)],
[], 1234, extra_info={"seeder": 2, "leecher": 3})
self.assertTrue(self.tdb.getTorrentID(infohash))
def test_add_external_torrent_no_def_invalid(self):
infohash = unhexlify('50865489ac16e2f34ea0cd3043cfd970cc24ec09')
self.tdb.addExternalTorrentNoDef(infohash, "test torrent", [("file1", {}), ("file2", 43)],
[], 1234)
self.assertFalse(self.tdb.getTorrentID(infohash))
def test_add_get_torrent_id(self):
infohash = str2bin('AA8cTG7ZuPsyblbRE7CyxsrKUCg=')
self.assertEqual(self.tdb.addOrGetTorrentID(infohash), 1)
new_infohash = unhexlify('50865489ac16e2f34ea0cd3043cfd970cc24ec09')
self.assertEqual(self.tdb.addOrGetTorrentID(new_infohash), 4859)
def test_add_get_torrent_ids_return(self):
infohash = str2bin('AA8cTG7ZuPsyblbRE7CyxsrKUCg=')
new_infohash = unhexlify('50865489ac16e2f34ea0cd3043cfd970cc24ec09')
tids, inserted = self.tdb.addOrGetTorrentIDSReturn([infohash, new_infohash])
self.assertEqual(tids, [1, 4859])
self.assertEqual(len(inserted), 1)
def test_index_torrent_existing(self):
self.tdb._indexTorrent(1, "test", [])
def test_getCollectedTorrentHashes(self):
res = self.tdb.getNumberCollectedTorrents()
self.assertEqual(res, 4847)
def test_freeSpace(self):
# Manually set the torrent store because register is not called.
self.session.lm.torrent_store = LevelDbStore(self.session.config.get_torrent_store_dir())
old_res = self.tdb.getNumberCollectedTorrents()
self.tdb.freeSpace(20)
res = self.tdb.getNumberCollectedTorrents()
self.session.lm.torrent_store.close()
self.assertEqual(res, old_res-20)
def test_get_search_suggestions(self):
self.assertEqual(self.tdb.getSearchSuggestion(["content", "cont"]), ["content 1"])
def test_get_autocomplete_terms(self):
self.assertEqual(len(self.tdb.getAutoCompleteTerms("content", 100)), 0)
def test_get_recently_randomly_collected_torrents(self):
self.assertEqual(len(self.tdb.getRecentlyCollectedTorrents(limit=10)), 10)
self.assertEqual(len(self.tdb.getRandomlyCollectedTorrents(100000000, limit=10)), 3)
def test_get_recently_checked_torrents(self):
self.assertEqual(len(self.tdb.getRecentlyCheckedTorrents(limit=5)), 5)
def test_select_torrents_to_collect(self):
infohash = str2bin('AA8cTG7ZuPsyblbRE7CyxsrKUCg=')
self.assertEqual(len(self.tdb.select_torrents_to_collect(infohash)), 0)
def test_get_torrents_stats(self):
self.assertEqual(self.tdb.getTorrentsStats(), (4847, 6519179841442, 187195))
def test_get_library_torrents(self):
self.assertEqual(len(self.tdb.getLibraryTorrents(['infohash'])), 12)
def test_search_names_no_sort(self):
"""
Test whether the right amount of torrents are returned when searching for torrents in db
"""
columns = ['T.torrent_id', 'infohash', 'status', 'num_seeders']
self.tdb.channelcast_db = ChannelCastDBHandler(self.session)
self.assertEqual(len(self.tdb.searchNames(['content'], keys=columns, doSort=False)), 4849)
self.assertEqual(len(self.tdb.searchNames(['content', '1'], keys=columns, doSort=False)), 1)
def test_search_names_sort(self):
"""
Test whether the right amount of sorted torrents are returned when searching for torrents in db
"""
columns = ['T.torrent_id', 'infohash', 'status', 'num_seeders']
self.tdb.channelcast_db = ChannelCastDBHandler(self.session)
results = self.tdb.searchNames(['content'], keys=columns)
self.assertEqual(len(results), 4849)
self.assertEqual(results[0][3], 493785)
def test_search_local_torrents(self):
"""
Test the search procedure in the local database when searching for torrents
"""
results = self.tdb.search_in_local_torrents_db('content', ['infohash', 'num_seeders'])
self.assertEqual(len(results), 4849)
self.assertNotEqual(results[0][-1], 0.0) # Relevance score of result should not be zero
results = self.tdb.search_in_local_torrents_db('fdsafasfds', ['infohash'])
self.assertEqual(len(results), 0)
def test_rel_score_remote_torrent(self):
self.tdb.latest_matchinfo_torrent = struct.pack("I" * 12, *([1] * 12)), "torrent"
self.assertNotEqual(self.tdb.relevance_score_remote_torrent("my-torrent.iso"), 0.0)