code: def test_app_state_with_env_var(mock_client):
      mock_client().lightningapp_instance_service_get_lightningapp_instance.return_value = Externalv1LightningappInstance(
          status=V1LightningappInstanceStatus(ip_address="test-ip"),
      )
      state = AppState()
      url = state._url
  
      mock_client().lightningapp_instance_service_get_lightningapp_instance.assert_called_once_with(
          "test-project-id",
          "test-app-id",
      )
  
      assert url == "http://test-ip:8080"
      assert not state._port
  
imports: import os
  from re import escape
  from unittest import mock
  import lightning.app
  import pytest
  import requests
  from lightning.app import LightningApp, LightningFlow, LightningWork
  from lightning.app.structures import Dict, List
  from lightning.app.utilities.app_helpers import AppStatePlugin, BaseStatePlugin
  from lightning.app.utilities.state import AppState
  from lightning_cloud.openapi import Externalv1LightningappInstance, V1LightningappInstanceStatus
label_desc: Use image node_id 10 for calling a global function with example usage: test_app_state_with_env_var(mock_client) without return types