code: def test_read_write_serde_v0_v1_with_compression(
      compression_type, magic
  ):
      builder = LegacyRecordBatchBuilder(
          magic=magic,
          compression_type=compression_type,
          batch_size=9999999,
      )
      for offset in range(10):
          builder.append(
              offset, timestamp=9999999, key=b"test", value=b"Super"
          )
      buffer = builder.build()
  
      batch = LegacyRecordBatch(bytes(buffer), magic)
      msgs = list(batch)
  
      for offset, msg in enumerate(msgs):
          assert msg.offset == offset
          assert msg.timestamp == (9999999 if magic else None)
          assert msg.timestamp_type == (0 if magic else None)
          assert msg.key == b"test"
          assert msg.value == b"Super"
          assert (
              msg.checksum
              == (-2095076219 if magic else 278251978) & 0xFFFFFFFF
          )
  
file_path: kafka-python/test/record/test_legacy_records.py
imports: from __future__ import unicode_literals
  import pytest
  from mock import patch
  from kafka.record.legacy_records import LegacyRecordBatch, LegacyRecordBatchBuilder
  import kafka.codec
  from kafka.errors import UnsupportedCodecError
label_desc: Use image node_id 2 for calling a global function with example usage: test_read_write_serde_v0_v1_with_compression(compression_type, magic) without return types