code: def test_is_ready(mocker, cli, conn):
      cli._maybe_connect(0)
      cli._maybe_connect(1)
  
      # metadata refresh blocks ready nodes
      assert cli.is_ready(0)
      assert cli.is_ready(1)
      cli._metadata_refresh_in_progress = True
      assert not cli.is_ready(0)
      assert not cli.is_ready(1)
  
      # requesting metadata update also blocks ready nodes
      cli._metadata_refresh_in_progress = False
      assert cli.is_ready(0)
      assert cli.is_ready(1)
      cli.cluster.request_update()
      cli.cluster.config["retry_backoff_ms"] = 0
      assert not cli._metadata_refresh_in_progress
      assert not cli.is_ready(0)
      assert not cli.is_ready(1)
      cli.cluster._need_update = False
  
      # if connection can't send more, not ready
      assert cli.is_ready(0)
      conn.can_send_more.return_value = False
      assert not cli.is_ready(0)
      conn.can_send_more.return_value = True
  
      # disconnected nodes, not ready
      assert cli.is_ready(0)
      conn.state = ConnectionStates.DISCONNECTED
      assert not cli.is_ready(0)
  
imports: from __future__ import absolute_import, division
  import socket
  import time
  import pytest
  from kafka.client_async import KafkaClient, IdleConnectionManager
  from kafka.cluster import ClusterMetadata
  from kafka.conn import ConnectionStates
  import kafka.errors
  from kafka.future import Future
  from kafka.protocol.metadata import MetadataRequest
  from kafka.protocol.produce import ProduceRequest
  from kafka.structs import BrokerMetadata
label_desc: Use image node_id 7 for calling a global function with example usage: test_is_ready(mocker, cli, conn) without return types