本文整理汇总了Python中Tribler.Test.Core.base_test.MockObject.files方法的典型用法代码示例。如果您正苦于以下问题:Python MockObject.files方法的具体用法?Python MockObject.files怎么用?Python MockObject.files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Test.Core.base_test.MockObject
的用法示例。
在下文中一共展示了MockObject.files方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_selected_files
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import files [as 别名]
def test_selected_files(self):
"""
Test whether the selected files are set correctly
"""
def mocked_set_file_prios(_):
mocked_set_file_prios.called = True
mocked_set_file_prios.called = False
mocked_file = MockObject()
mocked_file.path = 'my/path'
mock_torrent_info = MockObject()
mock_torrent_info.files = lambda: [mocked_file, mocked_file]
self.libtorrent_download_impl.handle.prioritize_files = mocked_set_file_prios
self.libtorrent_download_impl.handle.get_torrent_info = lambda: mock_torrent_info
self.libtorrent_download_impl.handle.rename_file = lambda *_: None
self.libtorrent_download_impl.get_share_mode = lambda: False
self.libtorrent_download_impl.tdef.get_infohash = lambda: 'a' * 20
self.libtorrent_download_impl.orig_files = ['a', 'b']
self.libtorrent_download_impl.get_save_path = lambda: 'my/path'
self.libtorrent_download_impl.set_selected_files(['a'])
self.assertTrue(mocked_set_file_prios.called)
self.libtorrent_download_impl.get_share_mode = lambda: False
mocked_set_file_prios.called = False
self.assertFalse(mocked_set_file_prios.called)
示例2: test_get_dest_files
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import files [as 别名]
def test_get_dest_files(self):
"""
Testing whether the right list of files is returned when fetching files from a download
"""
self.libtorrent_download_impl.handle.file_priority = lambda _: 123
mocked_file = MockObject()
mocked_file.path = 'test'
mock_torrent_info = MockObject()
mock_torrent_info.files = lambda: [mocked_file]
self.libtorrent_download_impl.handle.get_torrent_info = lambda: mock_torrent_info
dest_files = self.libtorrent_download_impl.get_dest_files()
self.assertIsInstance(dest_files[0], tuple)
self.assertEqual(dest_files[0][0], 'test')