'testing channel source.
It includes finding and downloading actual torrent'

@deferred(timeout=20)
def test_chn_lookup(self):

    self.create_fake_allchannel_community()
    self.create_torrents_in_channel(self.dispersy_cid_hex)
    self.boosting_manager.add_source(self.dispersy_cid)
    chn_obj = self.boosting_manager.get_source_object(self.dispersy_cid)
    def check_torrents_channel(src, defer_param=None, target=1):
        '\n                                                check    if    a    torrent    already    in    channel    and    ready    to    download\n                                                '
        if (defer_param is None):
            defer_param = defer.Deferred()
        src_obj = self.boosting_manager.get_source_object(src)
        success = True
        if ((not src_obj) or (len(src_obj.torrents) < target)):
            success = False
            reactor.callLater(1, check_torrents_channel, src, defer_param, target=target)
        elif (not self.boosting_manager.torrents.get(TORRENT_UBUNTU_FILE_INFOHASH, None)):
            success = False
            reactor.callLater(1, check_torrents_channel, src, defer_param, target=target)
        elif (not self.boosting_manager.torrents[TORRENT_UBUNTU_FILE_INFOHASH].get('download', None)):
            success = False
            reactor.callLater(1, check_torrents_channel, src, defer_param, target=target)
        if success:
            self.boosting_manager.set_enable_mining(src, False, force_restart=True)
            if src_obj.community:
                src_obj.community.cancel_all_pending_tasks()
            self.assertEqual(src_obj.get_source_text(), 'Simple    Channel')
            defer_param.callback(src)
        return defer_param
    chn_obj._load_torrent = self._load
    d = self.check_source(self.dispersy_cid)
    d.addCallback(check_torrents_channel, target=1)
    return d
