Ejemplo n.º 1
0
 def test_decode_produce_response(self):
     t1 = "topic1"
     t2 = "topic2"
     encoded = struct.pack(
         ">iih%dsiihqihqh%dsiihq" % (len(t1), len(t2)),
         2,
         2,
         len(t1),
         t1,
         2,
         0,
         0,
         10L,
         1,
         1,
         20L,
         len(t2),
         t2,
         1,
         0,
         0,
         30L,
     )
     responses = list(KafkaProtocol.decode_produce_response(encoded))
     self.assertEqual(
         responses, [ProduceResponse(t1, 0, 0, 10L), ProduceResponse(t1, 1, 1, 20L), ProduceResponse(t2, 0, 0, 30L)]
     )
Ejemplo n.º 2
0
 def test_decode_produce_response(self):
     t1 = "topic1"
     t2 = "topic2"
     encoded = struct.pack('>iih%dsiihqihqh%dsiihq' % (len(t1), len(t2)),
                           2, 2, len(t1), compat.bytes(t1), 2, 0, 0, compat.long(10), 1, 1, compat.long(20),
                           len(t2), compat.bytes(t2), 1, 0, 0, compat.long(30))
     responses = list(KafkaProtocol.decode_produce_response(encoded))
     self.assertEqual(responses,
                      [ProduceResponse(t1, 0, 0, compat.long(10)),
                       ProduceResponse(t1, 1, 1, compat.long(20)),
                       ProduceResponse(t2, 0, 0, compat.long(30))])
Ejemplo n.º 3
0
 def test_decode_produce_response(self):
     t1 = "topic1"
     t2 = "topic2"
     encoded = struct.pack('>iih%dsiihqihqh%dsiihq' % (len(t1), len(t2)),
                           2, 2, len(t1), t1, 2, 0, 0, 10L, 1, 1, 20L,
                           len(t2), t2, 1, 0, 0, 30L)
     responses = list(KafkaProtocol.decode_produce_response(encoded))
     self.assertEqual(responses, [
         ProduceResponse(t1, 0, 0, 10L),
         ProduceResponse(t1, 1, 1, 20L),
         ProduceResponse(t2, 0, 0, 30L)
     ])
Ejemplo n.º 4
0
 def test_decode_produce_response(self):
     t1 = "topic1"
     t2 = "topic2"
     encoded = struct.pack('>iih%dsiihqihqh%dsiihq' % (len(t1), len(t2)), 2,
                           2, len(t1), compat.bytes(t1), 2, 0, 0,
                           compat.long(10), 1, 1, compat.long(20), len(t2),
                           compat.bytes(t2), 1, 0, 0, compat.long(30))
     responses = list(KafkaProtocol.decode_produce_response(encoded))
     self.assertEqual(responses, [
         ProduceResponse(t1, 0, 0, compat.long(10)),
         ProduceResponse(t1, 1, 1, compat.long(20)),
         ProduceResponse(t2, 0, 0, compat.long(30))
     ])
Ejemplo n.º 5
0
 def test_decode_produce_response(self):
     t1 = b"topic1"
     t2 = b"topic2"
     _long = int
     if six.PY2:
         _long = long
     encoded = struct.pack('>iih%dsiihqihqh%dsiihq' % (len(t1), len(t2)),
                           2, 2, len(t1), t1, 2, 0, 0, _long(10), 1, 1, _long(20),
                           len(t2), t2, 1, 0, 0, _long(30))
     responses = list(KafkaProtocol.decode_produce_response(encoded))
     self.assertEqual(responses,
                      [ProduceResponse(t1, 0, 0, _long(10)),
                       ProduceResponse(t1, 1, 1, _long(20)),
                       ProduceResponse(t2, 0, 0, _long(30))])