code: def test_enable_port(monkeypatch):
      client = MagicMock()
      monkeypatch.setattr(
          port, "LightningClient", MagicMock(return_value=client)
      )
  
      assert _find_lit_app_port(5701) == 5701
  
      resp = MagicMock()
      lit_app = MagicMock()
      lit_app.id = "a"
      lit_app.spec.network_config = [
          V1NetworkConfig(host="a", port=0, enable=True),
          V1NetworkConfig(host="a", port=1, enable=False),
      ]
      resp.lightningapps = [lit_app]
      client.lightningapp_instance_service_list_lightningapp_instances.return_value = (
          resp
      )
  
      monkeypatch.setenv("LIGHTNING_CLOUD_APP_ID", "a")
      monkeypatch.setenv("LIGHTNING_CLOUD_PROJECT_ID", "a")
      monkeypatch.setenv(
          "ENABLE_MULTIPLE_WORKS_IN_DEFAULT_CONTAINER", "1"
      )
  
      assert enable_port()
  
      lit_app.spec.network_config = [
          V1NetworkConfig(host="a", port=0, enable=True),
          V1NetworkConfig(host="a", port=1, enable=True),
      ]
  
      with pytest.raises(
          RuntimeError, match="No available port was found. Please"
      ):
          assert enable_port()
  
file_path: pytorch-lightning/tests/tests_app/utilities/test_port.py
imports: from unittest.mock import MagicMock
  import pytest
  from lightning.app.utilities import port
  from lightning.app.utilities.port import _find_lit_app_port, disable_port, enable_port
  from lightning_cloud.openapi import V1NetworkConfig
label_desc: Use image node_id 2 for calling a global function with example usage: test_enable_port(monkeypatch) without return types