本文整理汇总了Python中Tribler.Test.Core.base_test.MockObject.name方法的典型用法代码示例。如果您正苦于以下问题:Python MockObject.name方法的具体用法?Python MockObject.name怎么用?Python MockObject.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Test.Core.base_test.MockObject
的用法示例。
在下文中一共展示了MockObject.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_conflicting_torrent_info
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import name [as 别名]
def test_update_conflicting_torrent_info(self):
""" Test updating torrent info response with existing record in the database."""
torrent_info_response = MockObject()
torrent_info_response.infohash = 'a' * 20
torrent_info_response.name = 'ubuntu'
torrent_info_response.length = 123
torrent_info_response.creation_date = 123123123
torrent_info_response.num_files = 2
torrent_info_response.comment = 'Ubuntu ISO'
self.content_repository.called_update_torrent = False
def fake_update_torrent(ref):
ref.called_update_torrent = True
def fake_get_torrent(infohash, name):
torrent = {'infohash': infohash, 'name': name}
return torrent
self.content_repository.torrent_db.updateTorrent = lambda infohash, **kw: fake_update_torrent(
self.content_repository)
self.content_repository.has_torrent = lambda infohash: True
self.content_repository.get_torrent = lambda infohash: fake_get_torrent(infohash, torrent_info_response.name)
self.content_repository.update_torrent_info(torrent_info_response)
self.assertFalse(self.content_repository.called_update_torrent)
示例2: test_update_torrent_info
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import name [as 别名]
def test_update_torrent_info(self):
""" Test updating torrent info """
self.content_repository.called_update_torrent = False
def fake_update_torrent(ref):
ref.called_update_torrent = True
self.content_repository.torrent_db.updateTorrent = lambda infohash, **kw: \
fake_update_torrent(self.content_repository)
self.content_repository.has_torrent = lambda infohash: False
torrent_info_response = MockObject()
torrent_info_response.infohash = 'a' * 20
torrent_info_response.name = 'ubuntu'
torrent_info_response.length = 123
torrent_info_response.creation_date = 123123123
torrent_info_response.num_files = 2
torrent_info_response.comment = 'Ubuntu ISO'
self.content_repository.update_torrent_info(torrent_info_response)
self.assertTrue(self.content_repository.called_update_torrent)