code: def test_cp_local_to_remote(tmpdir, monkeypatch):
      error_and_exit = MagicMock()
      monkeypatch.setattr(cp, "_error_and_exit", error_and_exit)
  
      client = MagicMock()
      client.projects_service_list_memberships.return_value = (
          V1ListMembershipsResponse(
              memberships=[V1Membership(name="project-0")]
          )
      )
  
      client.lightningapp_instance_service_list_lightningapp_instances.return_value = V1ListLightningappInstancesResponse(
          lightningapps=[
              Externalv1LightningappInstance(
                  name="app-name-0", id="app-id-0"
              )
          ]
      )
  
      client.projects_service_list_project_cluster_bindings.return_value = V1ListProjectClusterBindingsResponse(
          clusters=[
              V1ProjectClusterBinding(
                  cluster_id="my-cluster", cluster_name="my-cluster"
              )
          ]
      )
  
      result = MagicMock()
      result.get.return_value = V1UploadProjectArtifactResponse(
          urls=["http://foo.bar"]
      )
      client.lightningapp_instance_service_upload_project_artifact.return_value = (
          result
      )
  
      monkeypatch.setattr(
          cp, "LightningClient", MagicMock(return_value=client)
      )
  
      assert cd("/", verify=False) == "/"
      cp.cp(str(tmpdir), "r:.")
      assert (
          error_and_exit._mock_call_args_list[0].args[0]
          == "Uploading files at the project level isn't allowed yet."
      )
  
      assert (
          cd("/project-0/app-name-0", verify=False)
          == "/project-0/app-name-0"
      )
      with open(f"{tmpdir}/a.txt", "w") as f:
          f.write("hello world !")
  
      file_uploader = MagicMock()
      monkeypatch.setattr(cp, "FileUploader", file_uploader)
  
      cp.cp(str(tmpdir), "r:.")
      assert (
          file_uploader._mock_call_args[1]["name"] == f"{tmpdir}/a.txt"
      )
  
      os.remove(_CD_FILE)
  
file_path: pytorch-lightning/tests/tests_app/cli/test_cp.py
imports: import os
  import sys
  from pathlib import PosixPath
  from unittest.mock import MagicMock
  import pytest
  from lightning.app.cli.commands import cp
  from lightning.app.cli.commands.cd import _CD_FILE, cd
  from lightning_cloud.openapi import Externalv1Cluster, Externalv1LightningappInstance, V1CloudSpace, V1ClusterDriver, V1ClusterSpec, V1GetClusterResponse, V1KubernetesClusterDriver, V1LightningappInstanceArtifact, V1LightningappInstanceSpec, V1ListCloudSpacesResponse, V1ListClustersResponse, V1ListLightningappInstanceArtifactsResponse, V1ListLightningappInstancesResponse, V1ListMembershipsResponse, V1ListProjectClusterBindingsResponse, V1Membership, V1ProjectClusterBinding, V1UploadProjectArtifactResponse
label_desc: Use image node_id 1 for calling a global function with example usage: test_cp_local_to_remote(tmpdir, monkeypatch) without return types