code: def test_configure_commands(monkeypatch):
      """This test validates command can be used locally with connect and disconnect."""
      process = Process(target=target)
      process.start()
      time_left = 15
      while time_left > 0:
          try:
              requests.get(
                  f"http://localhost:{APP_SERVER_PORT}/healthz"
              )
              break
          except requests.exceptions.ConnectionError:
              sleep(0.1)
              time_left -= 0.1
  
      sleep(0.5)
      monkeypatch.setattr(
          sys,
          "argv",
          ["lightning", "user", "command", "--name=something"],
      )
      connect_app("localhost")
      _run_app_command("localhost", None)
      sleep(2)
      state = AppState()
      state._request_state()
      assert state.names == ["something"]
      monkeypatch.setattr(
          sys,
          "argv",
          [
              "lightning",
              "sweep",
              "--sweep_name=my_name",
              "--num_trials=1",
          ],
      )
      _run_app_command("localhost", None)
      time_left = 15
      while time_left > 0:
          if process.exitcode == 0:
              break
          sleep(0.1)
          time_left -= 0.1
      assert process.exitcode == 0
      disconnect_app()
      process.kill()
  
imports: import argparse
  import sys
  from multiprocessing import Process
  from time import sleep
  from unittest.mock import MagicMock
  import pytest
  import requests
  from lightning.app import LightningApp, LightningFlow
  from lightning.app.cli.commands.app_commands import _run_app_command
  from lightning.app.cli.connect.app import connect_app, disconnect_app
  from lightning.app.core.constants import APP_SERVER_PORT
  from lightning.app.runners import MultiProcessRuntime
  from lightning.app.testing.helpers import _RunIf
  from lightning.app.utilities.commands.base import ClientCommand, _download_command, _validate_client_command
  from lightning.app.utilities.state import AppState
  from pydantic import BaseModel
label_desc: Use image node_id 8 for calling a global function with example usage: test_configure_commands(monkeypatch) without return types