本文整理汇总了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)
示例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)
示例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
示例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')