code: def test_default_batch_size_limit():
      # First message can be added even if it's too big
      builder = DefaultRecordBatchBuilder(
          magic=2,
          compression_type=0,
          is_transactional=0,
          producer_id=-1,
          producer_epoch=-1,
          base_sequence=-1,
          batch_size=1024,
      )
  
      meta = builder.append(
          0, timestamp=None, key=None, value=b"M" * 2000, headers=[]
      )
      assert meta.size > 0
      assert meta.crc is None
      assert meta.offset == 0
      assert meta.timestamp is not None
      assert len(builder.build()) > 2000
  
      builder = DefaultRecordBatchBuilder(
          magic=2,
          compression_type=0,
          is_transactional=0,
          producer_id=-1,
          producer_epoch=-1,
          base_sequence=-1,
          batch_size=1024,
      )
      meta = builder.append(
          0, timestamp=None, key=None, value=b"M" * 700, headers=[]
      )
      assert meta is not None
      meta = builder.append(
          1, timestamp=None, key=None, value=b"M" * 700, headers=[]
      )
      assert meta is None
      meta = builder.append(
          2, timestamp=None, key=None, value=b"M" * 700, headers=[]
      )
      assert meta is None
      assert len(builder.build()) < 1000
  
file_path: kafka-python/test/record/test_default_records.py
imports: from __future__ import unicode_literals
  import pytest
  from mock import patch
  import kafka.codec
  from kafka.record.default_records import DefaultRecordBatch, DefaultRecordBatchBuilder
  from kafka.errors import UnsupportedCodecError
label_desc: Use image node_id 6 for calling a global function with example usage: test_default_batch_size_limit() without return types