code: def test_component_server_endpoints(connect):
      here = os.path.dirname(os.path.abspath(__file__))
      with gr.Blocks() as demo:
          file_explorer = gr.FileExplorer(root=here)
  
      with closing(demo) as io:
          app, _, _ = io.launch(prevent_thread_lock=True)
          client = TestClient(app)
          success_req = client.post(
              "/component_server/",
              json={
                  "session_hash": "123",
                  "component_id": file_explorer._id,
                  "fn_name": "ls",
                  "data": None,
              },
          )
          assert success_req.status_code == 200
          assert len(success_req.json()) > 0
          fail_req = client.post(
              "/component_server/",
              json={
                  "session_hash": "123",
                  "component_id": file_explorer._id,
                  "fn_name": "preprocess",
                  "data": None,
              },
          )
          assert fail_req.status_code == 404
  
imports: import functools
  import os
  import tempfile
  from contextlib import asynccontextmanager, closing
  from unittest import mock
  import gradio_client
  import numpy
  import pandas
  import pytest
  import starlette.routing
  from fastapi import FastAPI
  from fastapi.testclient import TestClient
  from gradio_client import media_data
  import gradio
  from gradio import Blocks, Button, Interface, Number, Textbox, close_all, routes, wasm_utils
  from gradio.route_utils import FnIndexInferError
label_desc: Use image node_id 9 for calling a global function with example usage: test_component_server_endpoints(connect) without return types