'Testing whether the API returns an error 500 if torrent is removed from a channel without community'

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

    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 mocked_get_community(_):
        raise CommunityNotFoundException('abcd')
    mock_dispersy = MockObject()
    mock_dispersy.get_community = mocked_get_community
    self.session.get_dispersy_instance = (lambda : mock_dispersy)
    url = ('channels/discovered/%s/torrents/%s' % ('fakedispersyid'.encode('hex'), ('a' * 40)))
    return self.do_request(url, expected_code=404, request_type='DELETE')
