code: def test_app_unhealthy(mocked_application_state):
      """Test DEPLOYING -> RUNNING -> UNHEALTHY -> RUNNING.
      Even after an application becomes running, if a deployment becomes
      unhealthy at some point, the application status should also be
      updated to unhealthy.
      """
      app_state, deployment_state_manager = mocked_application_state
      id_a, id_b = DeploymentID("a", "test_app"), DeploymentID(
          "b", "test_app"
      )
      app_state.deploy(
          {"a": deployment_info("a"), "b": deployment_info("b")}
      )
      assert app_state.status == ApplicationStatus.DEPLOYING
      app_state.update()
      assert app_state.status == ApplicationStatus.DEPLOYING
  
      # Once both deployments become healthy, app should be running
      deployment_state_manager.set_deployment_healthy(id_a)
      deployment_state_manager.set_deployment_healthy(id_b)
      app_state.update()
      assert app_state.status == ApplicationStatus.RUNNING
  
      # If a deployment becomes unhealthy, application should become unhealthy
      deployment_state_manager.set_deployment_unhealthy(id_a)
      app_state.update()
      assert app_state.status == ApplicationStatus.UNHEALTHY
      # Rerunning update shouldn't make a difference
      app_state.update()
      assert app_state.status == ApplicationStatus.UNHEALTHY
  
      # If the deployment recovers, the application should also recover
      deployment_state_manager.set_deployment_healthy(id_a)
      app_state.update()
      assert app_state.status == ApplicationStatus.RUNNING
  
imports: import sys
  from typing import Dict, List, Tuple
  from unittest.mock import Mock, PropertyMock, patch
  import pytest
  from ray.exceptions import RayTaskError
  from ray.serve._private.application_state import ApplicationState, ApplicationStateManager, override_deployment_info
  from ray.serve._private.common import ApplicationStatus, DeploymentID, DeploymentStatus, DeploymentStatusInfo, DeploymentStatusTrigger
  from ray.serve._private.config import DeploymentConfig, ReplicaConfig
  from ray.serve._private.deploy_utils import deploy_args_to_deployment_info
  from ray.serve._private.deployment_info import DeploymentInfo
  from ray.serve._private.test_utils import MockKVStore
  from ray.serve._private.utils import get_random_string
  from ray.serve.exceptions import RayServeException
  from ray.serve.schema import DeploymentSchema, ServeApplicationSchema
label_desc: Use image node_id 8 for calling a global function with example usage: test_app_unhealthy(mocked_application_state) without return types