docstr: Applies config with specified target_capacity.
docstr_tok: ["Applies","config","with","specified","target_capacity","."]
code: def apply_config_and_check_status(
      self,
      client: ServeControllerClient,
      target_capacity: Optional[float],
      config: ServeDeploySchema,
      app_name: str,
      deployment_name: str,
      expected_app_status: Optional[ApplicationStatus] = None,
      expected_deployment_status: Optional[DeploymentStatus] = None,
      expected_deployment_status_trigger: Optional[
          DeploymentStatusTrigger
      ] = None,
      timeout=10,
  ):
      """Applies config with specified target_capacity."""
  
      config = deepcopy(config)
      config.target_capacity = target_capacity
      client.deploy_apps(config)
      wait_for_condition(
          lambda: serve.status().target_capacity == target_capacity,
          timeout=timeout,
      )
  
      if expected_app_status is not None:
  
          def check_app_status():
              assert (
                  serve.status().applications[app_name].status
                  == expected_app_status
              )
              return True
  
          wait_for_condition(
              check_app_status,
              timeout=timeout,
          )
  
      if expected_deployment_status is not None:
  
          def check_deployment_status():
              assert (
                  serve.status()
                  .applications[app_name]
                  .deployments[deployment_name]
                  .status
                  == expected_deployment_status
              )
              return True
  
          wait_for_condition(check_deployment_status, timeout=timeout)
  
      if expected_deployment_status_trigger is not None:
  
          def check_status_trigger():
              assert (
                  serve.status()
                  .applications[app_name]
                  .deployments[deployment_name]
                  .status_trigger
                  == expected_deployment_status_trigger
              )
              return True
  
          wait_for_condition(
              check_status_trigger,
              timeout=timeout,
          )
  
imports: import asyncio
  import sys
  from copy import deepcopy
  from typing import Dict, Optional
  import pytest
  import ray
  from ray import serve
  from ray._private.pydantic_compat import BaseModel
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.exceptions import RayActorError
  from ray.serve import Application
  from ray.serve._private.client import ServeControllerClient
  from ray.serve._private.common import ApplicationStatus, DeploymentStatus, DeploymentStatusTrigger, ReplicaState, TargetCapacityDirection
  from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME, SERVE_NAMESPACE
  from ray.serve.config import AutoscalingConfig
  from ray.serve.context import _get_global_client
  from ray.serve.schema import ServeApplicationSchema, ServeDeploySchema
label_desc: Use image node_id 2 for calling the TestTargetCapacityUpdateAndServeStatus obj's underlying member method code with example usage: obj.apply_config_and_check_status(client, target_capacity, config, app_name, deployment_name, expected_app_status, expected_deployment_status, expected_deployment_status_trigger, timeout) and returns: True, True, True