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


Python MockObject.handle方法代码示例

本文整理汇总了Python中Tribler.Test.Core.base_test.MockObject.handle方法的典型用法代码示例。如果您正苦于以下问题:Python MockObject.handle方法的具体用法?Python MockObject.handle怎么用?Python MockObject.handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tribler.Test.Core.base_test.MockObject的用法示例。


在下文中一共展示了MockObject.handle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_remove_invalid_torrent

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import handle [as 别名]
 def test_remove_invalid_torrent(self):
     """
     Tests a successful removal status of torrents without a handle
     """
     self.ltmgr.initialize()
     mock_dl = MockObject()
     mock_dl.handle = None
     self.assertTrue(self.ltmgr.remove_torrent(mock_dl).called)
开发者ID:Tribler,项目名称:tribler,代码行数:10,代码来源:test_libtorrent_mgr.py

示例2: test_remove_invalid_handle_torrent

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import handle [as 别名]
 def test_remove_invalid_handle_torrent(self):
     """
     Tests a successful removal status of torrents with an invalid handle
     """
     self.ltmgr.initialize()
     mock_handle = MockObject()
     mock_handle.is_valid = lambda: False
     mock_dl = MockObject()
     mock_dl.handle = mock_handle
     self.assertTrue(self.ltmgr.remove_torrent(mock_dl).called)
开发者ID:Tribler,项目名称:tribler,代码行数:12,代码来源:test_libtorrent_mgr.py

示例3: setup_torrents

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import handle [as 别名]
        def setup_torrents(torrents):
            for i, torrent in enumerate(torrents):
                mock_status = MockObject()
                mock_status.total_upload = i * i
                mock_status.active_time = i

                mock_handle = MockObject()
                mock_handle.status = lambda status=mock_status: status

                mock_dl = MockObject()
                mock_dl.handle = mock_handle

                torrent.download = mock_dl
            return torrents
开发者ID:Tribler,项目名称:tribler,代码行数:16,代码来源:test_credit_mining_policies.py

示例4: test_upload_policy

# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import handle [as 别名]
    def test_upload_policy(self):
        for i, torrent in enumerate(self.torrents):
            mock_status = MockObject()
            mock_status.total_upload = i * i
            mock_status.active_time = i

            mock_handle = MockObject()
            mock_handle.status = lambda status=mock_status: status

            mock_dl = MockObject()
            mock_dl.handle = mock_handle

            torrent.download = mock_dl

        policy = UploadPolicy()
        sorted_torrents = policy.sort(self.torrents)
        expected_torrents = list(reversed(self.torrents))

        self.assertItemsEqual(sorted_torrents, expected_torrents, 'Arrays contains different torrents')
        self.assertListEqual(sorted_torrents, expected_torrents, 'Array is not sorted properly')
开发者ID:synctext,项目名称:tribler,代码行数:22,代码来源:test_credit_mining_policies.py


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