当前位置: 首页>>代码示例>>Python>>正文


Python MockObject.files方法代码示例

本文整理汇总了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)
开发者ID:synctext,项目名称:tribler,代码行数:29,代码来源:test_libtorrent_download_impl.py

示例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')
开发者ID:synctext,项目名称:tribler,代码行数:15,代码来源:test_libtorrent_download_impl.py


注:本文中的Tribler.Test.Core.base_test.MockObject.files方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。