本文整理汇总了Python中Tribler.Test.Core.base_test.MockObject.called_add方法的典型用法代码示例。如果您正苦于以下问题:Python MockObject.called_add方法的具体用法?Python MockObject.called_add怎么用?Python MockObject.called_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Test.Core.base_test.MockObject
的用法示例。
在下文中一共展示了MockObject.called_add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_torrent_no_playlist
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import called_add [as 别名]
def test_add_torrent_no_playlist(self):
"""
Testing whether an error 404 is returned when a torrent is added to a non-existing playlist
"""
mock_channel_community = MockObject()
mock_channel_community.called_add = False
self.create_fake_channel("channel", "")
mock_dispersy = MockObject()
mock_dispersy.get_community = lambda _: mock_channel_community
self.session.get_dispersy_instance = lambda: mock_dispersy
channel_cid = 'fakedispersyid'.encode('hex')
self.create_my_channel("my channel", "this is a short description")
return self.do_request('channels/discovered/%s/playlists/1/abcd' % channel_cid,
expected_code=404, request_type='PUT')
示例2: test_add_torrent_playlist
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import called_add [as 别名]
def test_add_torrent_playlist(self):
"""
Testing whether a torrent can successfully be added to a playlist
"""
mock_channel_community = MockObject()
mock_channel_community.called_add = False
my_channel_id = self.create_fake_channel("channel", "")
def verify_torrent_added(_):
self.assertTrue(mock_channel_community.called_add)
def modify_add_called(playlist_id, torrents):
self.assertEqual(playlist_id, 1)
self.assertEqual(torrents, [('a' * 40).decode('hex')])
mock_channel_community.called_add = True
mock_channel_community.create_playlist_torrents = modify_add_called
mock_dispersy = MockObject()
mock_dispersy.get_community = lambda _: mock_channel_community
self.session.get_dispersy_instance = lambda: mock_dispersy
self.create_playlist(my_channel_id, 1234, 42, "test playlist", "test description")
yield self.do_request('channels/discovered/%s/playlists/1/abcd' % 'fakedispersyid'.encode('hex'),
expected_code=404, request_type='PUT')
torrent_list = [[my_channel_id, 1, 1, ('a' * 40).decode('hex'), 1460000000, "ubuntu-torrent.iso",
[['file1.txt', 42]], []]]
self.insert_torrents_into_channel(torrent_list)
yield self.do_request('channels/discovered/%s/playlists/1/%s' % ('fakedispersyid'.encode('hex'), 'a' * 40),
expected_code=200, expected_json={'added': True}, request_type='PUT')\
.addCallback(verify_torrent_added)
self.insert_torrent_into_playlist(1234, ('a' * 40).decode('hex'))
yield self.do_request('channels/discovered/%s/playlists/1/%s' % ('fakedispersyid'.encode('hex'), 'a' * 40),
expected_code=409, request_type='PUT')