code: def test_run_job(
      mock_requests,
      mock_cloud_runtime,
      mock_cloud_backend,
      mock_plugin_server,
  ):
      """Tests that running a job from a plugin calls the correct `CloudRuntime` methods with the correct arguments."""
      content = as_tar_bytes("plugin.py", _plugin_with_job_run)
      mock_requests.get.side_effect = mock_requests_get(
          "http://test.tar.gz", content
      )
  
      body = _Run(
          plugin_entrypoint="plugin.py",
          source_code_url="http://test.tar.gz",
          project_id="test_project_id",
          cloudspace_id="test_cloudspace_id",
          cluster_id="test_cluster_id",
          plugin_arguments={
              "name": "test_name",
              "entrypoint": "test_entrypoint",
          },
          source_app="test_source_app",
      )
  
      mock_app = mock.MagicMock()
      mock_cloud_runtime.load_app_from_file.return_value = mock_app
      mock_cloud_runtime.return_value.cloudspace_dispatch.return_value = Externalv1LightningappInstance(
          id="created_app_id"
      )
  
      response = mock_plugin_server.post(
          "/v1/runs", json=body.dict(exclude_none=True)
      )
  
      assert response.status_code == status.HTTP_200_OK, response.json()
      assert json.loads(response.text)["id"] == "created_app_id"
  
      mock_cloud_runtime.load_app_from_file.assert_called_once()
      assert (
          "test_entrypoint"
          in mock_cloud_runtime.load_app_from_file.call_args[0][0]
      )
  
      mock_cloud_runtime.assert_called_once_with(
          app=mock_app,
          entrypoint=Path("test_entrypoint"),
          start_server=True,
          env_vars={},
          secrets={},
          run_app_comment_commands=True,
          backend=mock.ANY,
      )
  
      mock_cloud_runtime().cloudspace_dispatch.assert_called_once_with(
          project_id=body.project_id,
          cloudspace_id=body.cloudspace_id,
          name="test_name",
          cluster_id=body.cluster_id,
          source_app=body.source_app,
      )
  
file_path: pytorch-lightning/tests/tests_app/plugin/test_plugin.py
imports: import io
  import json
  import sys
  import tarfile
  from dataclasses import dataclass
  from pathlib import Path
  from unittest import mock
  import pytest
  from fastapi import status
  from fastapi.testclient import TestClient
  from lightning.app.plugin.plugin import _Run, _start_plugin_server
  from lightning_cloud.openapi import Externalv1LightningappInstance
label_desc: Use image node_id 5 for calling a global function with example usage: test_run_job(mock_requests, mock_cloud_runtime, mock_cloud_backend, mock_plugin_server) without return types