class_docstr: Abstract class for end-to-end tests of Mephisto-based crowdsourcing tasks.
  
  Allows for setup and teardown of the operator, as well as for config specification
  and agent registration.
class_docstr_tok: ["Abstract","class","for","end-to-end","tests","of","Mephisto-based","crowdsourcing","tasks",".","Allows","for","setup","and","teardown","of","the","operator",",","as","well","as","for","config","specification","and","agent","registration","."]
docstr: Register mock agents for testing and onboard them if needed, taking the place of
  crowdsourcing workers.
  
  Specify the number of agents to register. Return the agents' IDs after creation.
code: def _register_mock_agents(
      self, num_agents: int = 1, assume_onboarding: bool = False
  ) -> List[str]:
      """
      Register mock agents for testing and onboard them if needed, taking the place of
      crowdsourcing workers.
  
      Specify the number of agents to register. Return the agents' IDs after creation.
      """
  
      for idx in range(num_agents):
          mock_worker_registration_name = f"MOCK_WORKER_{idx:d}"
          mock_worker_name = f"{mock_worker_registration_name}_sandbox"
  
          # Register the agent
          mock_agent_details = f"FAKE_ASSIGNMENT_{idx:d}"
          self.server.register_mock_agent(
              mock_worker_registration_name, mock_agent_details
          )
          self.assert_sandbox_worker_created(mock_worker_name)
          workers = self.db.find_workers(worker_name=mock_worker_name)
          print(
              "Workers:",
              workers,
              self.db.find_workers(),
              [w.worker_name for w in self.db.find_workers()],
          )
          worker_id = workers[0].db_id
  
          if assume_onboarding:
              # Submit onboarding from the agent
              onboard_agents = self.db.find_onboarding_agents()
              onboard_data = {"onboarding_data": {"success": True}}
              self.server.register_mock_agent_after_onboarding(
                  worker_id,
                  onboard_agents[0].get_agent_id(),
                  onboard_data,
              )
              self.await_channel_requests()
          self.await_channel_requests()
          print("Agents:", self.db.find_agents())
  
          # Make sure the agent can be found
          try:
              _ = self.db.find_agents()[idx]
          except IndexError:
              raise ValueError("The agent could not be registered!")
  
      # Get all agents' IDs
      agents = self.db.find_agents()
      if len(agents) != num_agents:
          raise ValueError(
              f"The actual number of agents is {len(agents):d} instead of the "
              f"desired {num_agents:d}!"
          )
      agent_ids = [agent.db_id for agent in agents]
  
      return agent_ids
  
imports: import os
  import random
  import tempfile
  import time
  import unittest
  from typing import Any, Dict, List, Optional, Sequence, Union
  import numpy
  import torch
  from parlai.utils import logging
  from hydra.experimental import compose, initialize
  from mephisto.abstractions.blueprint import SharedTaskState
  from mephisto.abstractions.databases.local_database import LocalMephistoDB
  from mephisto.data_model.task_run import TaskRunArgs
  from mephisto.operations.operator import Operator
  from mephisto.tools.scripts import augment_config_from_db
  from mephisto.utils.metrics import InaccessiblePrometheusServer
  from pytest_regressions.data_regression import DataRegressionFixture
label_desc: Use image node_id 8 for calling the AbstractCrowdsourcingTest obj's underlying member method code with example usage: obj._register_mock_agents(num_agents, assume_onboarding) and returns: agent_ids