code: def test_unavailable_codec(
      magic, compression_type, name, checker_name
  ):
      builder = DefaultRecordBatchBuilder(
          magic=2,
          compression_type=compression_type,
          is_transactional=0,
          producer_id=-1,
          producer_epoch=-1,
          base_sequence=-1,
          batch_size=1024,
      )
      builder.append(
          0, timestamp=None, key=None, value=b"M" * 2000, headers=[]
      )
      correct_buffer = builder.build()
  
      with patch.object(kafka.codec, checker_name) as mocked:
          mocked.return_value = False
          # Check that builder raises error
          builder = DefaultRecordBatchBuilder(
              magic=2,
              compression_type=compression_type,
              is_transactional=0,
              producer_id=-1,
              producer_epoch=-1,
              base_sequence=-1,
              batch_size=1024,
          )
          error_msg = (
              "Libraries for {} compression codec not found".format(
                  name
              )
          )
          with pytest.raises(UnsupportedCodecError, match=error_msg):
              builder.append(
                  0, timestamp=None, key=None, value=b"M", headers=[]
              )
              builder.build()
  
          # Check that reader raises same error
          batch = DefaultRecordBatch(bytes(correct_buffer))
          with pytest.raises(UnsupportedCodecError, match=error_msg):
              list(batch)
  
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 7 for calling a global function with example usage: test_unavailable_codec(magic, compression_type, name, checker_name) without return types