本文整理汇总了Python中Tribler.Test.Core.base_test.MockObject.set_priority方法的典型用法代码示例。如果您正苦于以下问题:Python MockObject.set_priority方法的具体用法?Python MockObject.set_priority怎么用?Python MockObject.set_priority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Test.Core.base_test.MockObject
的用法示例。
在下文中一共展示了MockObject.set_priority方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import set_priority [as 别名]
def setUp(self):
TriblerCoreTest.setUp(self)
self.libtorrent_download_impl = LibtorrentDownloadImpl(None, None)
mock_handle = MockObject()
mock_status = MockObject()
mock_status.pieces = [True, False, True, True, False]
torrent_info = MockObject()
file_info = MockObject()
file_info.size = 1234
torrent_info.file_at = lambda _: file_info
map_file_result = MockObject()
map_file_result.piece = 123
torrent_info.map_file = lambda _dummy1, _dummy2, _dummy3: map_file_result
torrent_info.num_pieces = lambda: 5
mock_handle.is_valid = lambda: True
mock_handle.status = lambda: mock_status
mock_handle.get_torrent_info = lambda: torrent_info
mock_handle.set_sequential_download = lambda _: None
mock_handle.set_priority = lambda _: None
mock_handle.prioritize_pieces = lambda _: None
self.libtorrent_download_impl.handle = mock_handle
# Create a fake tdef
self.libtorrent_download_impl.tdef = MockObject()
self.libtorrent_download_impl.tdef.get_name = lambda: "ubuntu.iso"
self.libtorrent_download_impl.tdef.is_multifile_torrent = lambda: False
示例2: test_multifile_torrent
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import set_priority [as 别名]
def test_multifile_torrent(self):
tdef = TorrentDef()
tdef.add_content(os.path.join(TESTS_DATA_DIR, "video.avi"))
tdef.set_tracker("http://tribler.org/announce")
tdef.save()
impl = LibtorrentDownloadImpl(self.session, tdef)
# Override the add_torrent because it will be called
impl.ltmgr = MockObject()
impl.ltmgr.add_torrent = lambda _, _dummy2: succeed(fake_handler)
impl.set_selected_files = lambda: None
fake_handler = MockObject()
fake_handler.is_valid = lambda: True
fake_handler.status = lambda: fake_status
fake_handler.set_share_mode = lambda _: None
fake_handler.set_priority = lambda _: None
fake_handler.set_sequential_download = lambda _: None
fake_handler.resume = lambda: None
fake_handler.set_max_connections = lambda _: None
fake_status = MockObject()
fake_status.share_mode = False
# Create a dummy download config
impl.dlconfig = DownloadStartupConfig().dlconfig.copy()
# Create a dummy pstate
pstate = CallbackConfigParser()
pstate.add_section("state")
test_dict = dict()
test_dict["a"] = "b"
pstate.set("state", "engineresumedata", test_dict)
return impl.network_create_engine_wrapper(pstate)