'Testing whether adding a torrent with a description to a channel works'

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

    my_channel_id = self.create_fake_channel('channel', '')
    torrent_path = TORRENT_UBUNTU_FILE
    def verify_method_invocation(channel_id, torrent_def, extra_info=None, forward=True):
        self.assertEqual(my_channel_id, channel_id)
        self.assertEqual(TorrentDef.load(torrent_path), torrent_def)
        self.assertEqual({'description': 'video    of    my    cat'}, (extra_info or {}))
        self.assertEqual(True, forward)
    self.session.add_torrent_def_to_channel = verify_method_invocation
    with open(torrent_path, mode='rb') as torrent_file:
        torrent_64 = base64.b64encode(torrent_file.read())
    post_data = {'torrent': torrent_64, 'description': 'video    of    my    cat'}
    expected_json = {'added': True}
    return self.do_request(('channels/discovered/%s/torrents' % 'fakedispersyid'.encode('hex')), 200, expected_json, 'PUT', post_data)
