code: def test_client_websocket(mocker, flow_with_websocket):
      with flow_with_websocket:
          time.sleep(0.5)
          client = Client(
              host="localhost",
              port=str(flow_with_websocket.port),
              protocol="websocket",
          )
          # Test that a regular index request triggers the correct callbacks
          on_always_mock = mocker.Mock()
          on_error_mock = mocker.Mock()
          on_done_mock = mocker.Mock()
          client.post(
              "",
              random_docs(1),
              request_size=1,
              on_always=on_always_mock,
              on_error=on_error_mock,
              on_done=on_done_mock,
              return_responses=True,
          )
          on_always_mock.assert_called_once()
          on_done_mock.assert_called_once()
          on_error_mock.assert_not_called()
  
imports: import os
  import time
  import pytest
  import requests
  from jina import Deployment, Executor, Flow, helper
  from jina import requests
  from jina.clients import Client
  from jina.orchestrate.pods.factory import PodFactory
  from jina.parsers import set_gateway_parser
  from tests import random_docs
label_desc: Use image node_id 8 for calling a global function with example usage: test_client_websocket(mocker, flow_with_websocket) without return types