code: def test_update_work_with_changed_compute_config_and_build_spec(
      mock_client,
  ):
      cloud_backend = CloudBackend("")
      matching_spec = Mock()
      app = MagicMock()
      work = EmptyWork(
          cloud_compute=CloudCompute("default"),
          cloud_build_config=BuildConfig(image="image1"),
      )
      work._name = "work_name"
  
      matching_spec.spec = cloud_backend._work_to_spec(work)
      matching_spec.spec.desired_state = V1LightningworkState.STOPPED
      matching_spec.name = "work_name"
  
      response_mock = Mock()
      response_mock.lightningworks = [matching_spec]
      mock_client().lightningwork_service_list_lightningwork.return_value = (
          response_mock
      )
  
      cloud_backend.create_work(app, work)
      assert (
          cloud_backend.client.lightningwork_service_update_lightningwork._mock_call_args.kwargs[
              "body"
          ].spec.desired_state
          == V1LightningworkState.RUNNING
      )
      assert (
          cloud_backend.client.lightningwork_service_update_lightningwork._mock_call_args.kwargs[
              "body"
          ].spec.user_requested_compute_config.name
          == "cpu-small"
      )
      assert (
          cloud_backend.client.lightningwork_service_update_lightningwork._mock_call_args.kwargs[
              "body"
          ].spec.build_spec.image
          == "image1"
      )
  
      # resetting the values changed in the previous step
      matching_spec.spec.desired_state = V1LightningworkState.STOPPED
      cloud_backend.client.lightningwork_service_update_lightningwork.reset_mock()
  
      # new work with same name but different compute config
      work = EmptyWork(
          cloud_compute=CloudCompute("gpu"),
          cloud_build_config=BuildConfig(image="image2"),
      )
      work._name = "work_name"
      cloud_backend.create_work(app, work)
      assert (
          cloud_backend.client.lightningwork_service_update_lightningwork._mock_call_args.kwargs[
              "body"
          ].spec.desired_state
          == V1LightningworkState.RUNNING
      )
      assert (
          cloud_backend.client.lightningwork_service_update_lightningwork._mock_call_args.kwargs[
              "body"
          ].spec.user_requested_compute_config.name
          == "gpu"
      )
      assert (
          cloud_backend.client.lightningwork_service_update_lightningwork._mock_call_args.kwargs[
              "body"
          ].spec.build_spec.image
          == "image2"
      )
  
imports: import json
  import os
  from copy import copy
  from datetime import datetime
  from unittest import mock
  from unittest.mock import ANY, MagicMock, Mock
  import pytest
  from lightning.app import BuildConfig, CloudCompute, LightningWork
  from lightning.app.launcher.lightning_backend import CloudBackend
  from lightning.app.storage import Drive, Mount
  from lightning.app.testing.helpers import EmptyWork
  from lightning.app.utilities.enum import WorkFailureReasons, WorkStageStatus
  from lightning.app.utilities.exceptions import LightningPlatformException
  from lightning_cloud.openapi import Body5, V1DriveType, V1LightningworkState, V1SourceType
  from lightning_cloud.openapi.rest import ApiException
label_desc: Use image node_id 13 for calling a global function with example usage: test_update_work_with_changed_compute_config_and_build_spec(mock_client) without return types