def test_decode_produce_response(self): t1 = "topic1" t2 = u"topic2" encoded = struct.pack('>iih%dsiihqihqh%dsiihq' % (len(t1), len(t2)), 2, 2, len(t1), t1.encode(), 2, 0, 0, 10, 1, 1, 20, len(t2), t2.encode(), 1, 0, 0, 30) responses = list(KafkaCodec.decode_produce_response(encoded)) self.assertEqual(responses, [ProduceResponse(t1, 0, 0, 10), ProduceResponse(t1, 1, 1, 20), ProduceResponse(t2, 0, 0, 30)])
def test_decode_produce_response(self): t1 = b"topic1" t2 = b"topic2" encoded = struct.pack('>iih%dsiihqihqh%dsiihq' % (len(t1), len(t2)), 2, 2, len(t1), t1, 2, 0, 0, 10, 1, 1, 20, len(t2), t2, 1, 0, 0, 30) responses = list(KafkaCodec.decode_produce_response(encoded)) self.assertEqual(responses, [ ProduceResponse(t1, 0, 0, 10), ProduceResponse(t1, 1, 1, 20), ProduceResponse(t2, 0, 0, 30) ])
def test_decode_produce_response(self): t1 = "topic1" t2 = u"topic2" encoded = struct.pack('>iih%dsiihqlihqlh%dsiihql' % (len(t1), len(t2)), 2, 2, len(t1), t1.encode(), 2, 0, 0, 10, 4, 1, 1, 20, 5, len(t2), t2.encode(), 1, 0, 0, 30, 6) responses = list(KafkaCodec.decode_produce_response(encoded)) self.assertEqual(responses, [ ProduceResponse(t1, 0, 0, 10, 4), ProduceResponse(t1, 1, 1, 20, 5), ProduceResponse(t2, 0, 0, 30, 6) ])