'Testing whether the API can remove a torrent from a channel'

@deferred(timeout=10)
def test_remove_torrent(self):

    mock_channel_community = MockObject()
    mock_channel_community.called_remove = False
    def verify_torrent_removed(_):
        self.assertTrue(mock_channel_community.called_remove)
    channel_id = self.create_fake_channel('channel', '')
    torrent_list = [[channel_id, 1, 1, ('a' * 40).decode('hex'), 1460000000, 'ubuntu-torrent.iso', [['file1.txt', 42]], []]]
    self.insert_torrents_into_channel(torrent_list)
    def remove_torrents_called(_):
        mock_channel_community.called_remove = True
    mock_channel_community.remove_torrents = remove_torrents_called
    mock_dispersy = MockObject()
    mock_dispersy.get_community = (lambda _: mock_channel_community)
    self.session.get_dispersy_instance = (lambda : mock_dispersy)
    self.should_check_equality = False
    url = ('channels/discovered/%s/torrents/%s' % ('fakedispersyid'.encode('hex'), ('a' * 40)))
    return self.do_request(url, expected_code=200, request_type='DELETE').addCallback(verify_torrent_removed)
