'Test whether adding a torrent def to a channel works'

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

    test_deferred = Deferred()
    torrent_def = TorrentDef.load(TORRENT_UBUNTU_FILE)
    @blocking_call_on_reactor_thread
    def on_channel_created(subject, change_type, object_id, channel_data):
        channel_id = self.channel_db_handler.getMyChannelId()
        self.session.add_torrent_def_to_channel(channel_id, torrent_def, {'description': 'iso'}, forward=False)
        self.assertTrue(self.channel_db_handler.hasTorrent(channel_id, torrent_def.get_infohash()))
        test_deferred.callback(None)
    self.session.add_observer(on_channel_created, SIGNAL_CHANNEL, [SIGNAL_ON_CREATED])
    self.session.create_channel('name', 'description', 'open')
    return test_deferred
