code: def test_grpc_client_credentials_are_passed_to_channel(monkeypatch):
      class Stop(Exception):
          def __init__(self, credentials):
              self.credentials = credentials
  
      class MockChannel:
          def __init__(
              self, conn_str, credentials, options, compression
          ):
              self.credentials = credentials
  
          def subscribe(self, f):
              raise Stop(self.credentials)
  
      def mock_secure_channel(
          conn_str, credentials, options=None, compression=None
      ):
          return MockChannel(
              conn_str, credentials, options, compression
          )
  
      monkeypatch.setattr(grpc, "secure_channel", mock_secure_channel)
  
      # Credentials should be respected whether secure is set or not.
  
      with pytest.raises(Stop) as stop:
          Worker(secure=False, _credentials=Credentials("test"))
      assert stop.value.credentials.name == "test"
  
      with pytest.raises(Stop) as stop:
          Worker(secure=True, _credentials=Credentials("test"))
      assert stop.value.credentials.name == "test"
  
file_path: ray/python/ray/tests/test_grpc_client_credentials.py
imports: import pytest
  import grpc
  from ray.util.client.worker import Worker
label_desc: Use image node_id 1 for calling a global function with example usage: test_grpc_client_credentials_are_passed_to_channel(monkeypatch) and returns: MockChannel