code: def test_sweep_scheduler_base_add_to_launch_queue(
      user, sweep_config, monkeypatch
  ):
      _patch_wandb_run(monkeypatch)
      api = internal.Api()
  
      _project = "test-project"
      _job = "test-job:latest"
      sweep_id = wandb.sweep(
          sweep_config, entity=user, project=_project
      )
  
      async def mock_launch_add(*args, **kwargs):
          mock = Mock(spec=public.QueuedRun)
          mock.args = Mock(return_value=args)
          return mock
  
      monkeypatch.setattr(
          "wandb.sdk.launch._launch_add._launch_add",
          mock_launch_add,
      )
  
      def mock_get_run_state(*args, **kwargs):
          if args[2] == "sweep-scheduler":
              return "running"
          return "finished"
  
      api.get_run_state = mock_get_run_state
  
      def mock_run_add_to_launch_queue(self, *args, **kwargs):
          self._runs["foo_run"] = SweepRun(
              id="foo_run",
              worker_id=0,
              args={"foo": {"value": 1}},
          )
          self._add_to_launch_queue(self._runs["foo_run"])
          self.state = SchedulerState.COMPLETED
          self.exit()
  
      monkeypatch.setattr(
          "wandb.sdk.launch.sweeps.scheduler.Scheduler._get_next_sweep_run",
          mock_run_add_to_launch_queue,
      )
  
      monkeypatch.setattr(
          "wandb.sdk.launch.sweeps.scheduler.Scheduler._try_load_executable",
          lambda _: True,
      )
  
      def mock_stop_run(self, run_id):
          self._runs[run_id].state = RunState.CRASHED
          return True
  
      monkeypatch.setattr(
          "wandb.sdk.launch.sweeps.scheduler.Scheduler._stop_run",
          mock_stop_run,
      )
  
      _scheduler = Scheduler(
          api,
          sweep_id=sweep_id,
          entity=user,
          project=_project,
          project_queue=_project,
          polling_sleep=0,
          num_workers=1,
          job=_job,
      )
      assert _scheduler.state == SchedulerState.PENDING
      assert _scheduler.is_alive is True
      assert _scheduler._project_queue == _project
      _scheduler.start()
      assert _scheduler.state == SchedulerState.COMPLETED
      assert _scheduler.is_alive is False
      assert len(_scheduler._runs) == 1
      assert isinstance(
          _scheduler._runs["foo_run"].queued_run, public.QueuedRun
      )
      _scheduler._runs["foo_run"].queued_run.state = RunState.FINISHED
      assert (
          _scheduler._runs["foo_run"].queued_run.args()[-2] == _project
      )
  
      sweep_id2 = wandb.sweep(
          sweep_config, entity=user, project=_project
      )
      _project_queue = "test-project-queue"
      _scheduler2 = Scheduler(
          api,
          sweep_id=sweep_id2,
          entity=user,
          project=_project,
          project_queue=_project_queue,
          polling_sleep=0,
          job=_job,
      )
      _scheduler2.start()
      assert len(_scheduler2.busy_workers) == 1
      assert len(_scheduler2.available_workers) == 7
      assert (
          _scheduler2._runs["foo_run"].queued_run.args()[-2]
          == _project_queue
      )
  
imports: import asyncio
  from typing import Dict
  from unittest.mock import Mock, patch
  import pytest
  import wandb
  from wandb.apis import internal, public
  from wandb.errors import CommError
  from wandb.sdk.launch.sweeps import SchedulerError, load_scheduler
  from wandb.sdk.launch.sweeps.scheduler import RunState, Scheduler, SchedulerState, SweepRun
  from wandb.sdk.launch.sweeps.scheduler_sweep import SweepScheduler
  from wandb.sdk.launch.sweeps.utils import construct_scheduler_args
  from .test_wandb_sweep import VALID_SWEEP_CONFIGS_MINIMAL
label_desc: Use image node_id 10 for calling a global function with example usage: test_sweep_scheduler_base_add_to_launch_queue(user, sweep_config, monkeypatch) and returns: mock, str, True, str