'Test the decoding of a torrent message'

def test_decode_torrent(self):

    self.assertRaises(DropPacket, self.conversion._decode_torrent, None, 0, 'abcd')
    self.assertRaises(DropPacket, self.conversion._decode_torrent, None, 0, zlib.compress('abcd'))
    meta = self.channel_community.get_meta_message(u'torrent')
    msg = MockObject()
    msg.meta = meta
    torrent_msg = encode((pack('!20sQ', ('a' * 20), 12345), u'torrent', ((u'a', 1234),), ('http://track.er',)))
    (_, msg) = self.conversion._decode_torrent(msg, 0, zlib.compress(torrent_msg))
    self.assertEqual(msg.infohash, ('a' * 20))
    self.assertEqual(msg.name, u'torrent')
