本文整理汇总了Python中Tribler.Test.Core.base_test.MockObject.called_remove方法的典型用法代码示例。如果您正苦于以下问题:Python MockObject.called_remove方法的具体用法?Python MockObject.called_remove怎么用?Python MockObject.called_remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tribler.Test.Core.base_test.MockObject
的用法示例。
在下文中一共展示了MockObject.called_remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_torrent_playlist
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import called_remove [as 别名]
def test_remove_torrent_playlist(self):
"""
Testing whether a torrent can be successfully removed from a playlist
"""
mock_channel_community = MockObject()
mock_channel_community.called_remove = False
my_channel_id = self.create_fake_channel("channel", "")
def verify_torrent_removed(_):
self.assertTrue(mock_channel_community.called_remove)
def modify_remove_called(playlist_id, torrents):
self.assertEqual(playlist_id, 1)
self.assertEqual(torrents, [42])
mock_channel_community.called_remove = True
mock_channel_community.remove_playlist_torrents = modify_remove_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='DELETE')
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)
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=200, request_type='DELETE', expected_json={'removed': True})\
.addCallback(verify_torrent_removed)
示例2: test_delete_playlist
# 需要导入模块: from Tribler.Test.Core.base_test import MockObject [as 别名]
# 或者: from Tribler.Test.Core.base_test.MockObject import called_remove [as 别名]
def test_delete_playlist(self):
"""
Testing whether a playlist is correctly removed
"""
mock_channel_community = MockObject()
mock_channel_community.called_remove = False
mock_channel_community.called_remove_torrents = False
my_channel_id = self.create_fake_channel("channel", "")
def verify_playlist_removed(_):
self.assertTrue(mock_channel_community.called_remove_torrents)
self.assertTrue(mock_channel_community.called_remove)
def remove_playlist_called(playlists):
self.assertEqual(playlists, [1234])
mock_channel_community.called_remove = True
def remove_torrents_called(playlist_id, torrents):
self.assertEqual(playlist_id, 1234)
self.assertEqual(torrents, [42])
mock_channel_community.called_remove_torrents = True
mock_channel_community.remove_playlists = remove_playlist_called
mock_channel_community.remove_playlist_torrents = remove_torrents_called
mock_dispersy = MockObject()
mock_dispersy.get_community = lambda _: mock_channel_community
self.session.get_dispersy_instance = lambda: mock_dispersy
# Create a playlist and add a torrent to it
self.create_playlist(my_channel_id, 1234, 42, "test playlist", "test description")
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)
self.insert_torrent_into_playlist(1234, ('a' * 40).decode('hex'))
return self.do_request('channels/discovered/%s/playlists/1' % 'fakedispersyid'.encode('hex'),
expected_code=200, expected_json={"removed": True},
request_type='DELETE').addCallback(verify_playlist_removed)