code: def test_default_batch_builder_validates_arguments():
      builder = DefaultRecordBatchBuilder(
          magic=2,
          compression_type=0,
          is_transactional=0,
          producer_id=-1,
          producer_epoch=-1,
          base_sequence=-1,
          batch_size=999999,
      )
  
      # Key should not be str
      with pytest.raises(TypeError):
          builder.append(
              0,
              timestamp=9999999,
              key="some string",
              value=None,
              headers=[],
          )
  
      # Value should not be str
      with pytest.raises(TypeError):
          builder.append(
              0,
              timestamp=9999999,
              key=None,
              value="some string",
              headers=[],
          )
  
      # Timestamp should be of proper type
      with pytest.raises(TypeError):
          builder.append(
              0,
              timestamp="1243812793",
              key=None,
              value=b"some string",
              headers=[],
          )
  
      # Offset of invalid type
      with pytest.raises(TypeError):
          builder.append(
              "0",
              timestamp=9999999,
              key=None,
              value=b"some string",
              headers=[],
          )
  
      # Ok to pass value as None
      builder.append(
          0, timestamp=9999999, key=b"123", value=None, headers=[]
      )
  
      # Timestamp can be None
      builder.append(
          1, timestamp=None, key=None, value=b"some string", headers=[]
      )
  
      # Ok to pass offsets in not incremental order. This should not happen thou
      builder.append(
          5, timestamp=9999999, key=b"123", value=None, headers=[]
      )
  
      # Check record with headers
      builder.append(
          6,
          timestamp=9999999,
          key=b"234",
          value=None,
          headers=[("hkey", b"hval")],
      )
  
      # in case error handling code fails to fix inner buffer in builder
      assert len(builder.build()) == 124
  
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 4 for calling a global function with example usage: test_default_batch_builder_validates_arguments() without return types