code: def test_layout_leaf_node(find_ports_mock, flow):
      find_ports_mock.side_effect = lambda: 100
      flow = flow()
      app = LightningApp(flow)
      assert flow._layout == {}
      # we copy the dict here because after we dispatch the dict will get update with new instances
      # as the layout gets updated during the loop.
      frontends = app.frontends.copy()
      MultiProcessRuntime(app).dispatch()
      assert flow.counter == 3
  
      # The target url is available for the frontend after we started the servers in dispatch
      assert flow._layout == {"target": "http://localhost:100/root"}
      assert app.frontends[flow.name].flow is flow
  
      # we start the servers for the frontends that we collected at the time of app instantiation
      frontends[flow.name].start_server.assert_called_once()
  
      # leaf layout nodes can't be changed, they stay the same from when they first got configured
      assert app.frontends[flow.name] == frontends[flow.name]
  
imports: from re import escape
  from unittest import mock
  from unittest.mock import Mock
  import pytest
  from lightning.app import LightningApp, LightningFlow
  from lightning.app.frontend.stream_lit import StreamlitFrontend
  from lightning.app.frontend.web import StaticWebFrontend
  from lightning.app.runners import MultiProcessRuntime
  from lightning.app.testing.helpers import EmptyFlow
  from lightning.app.utilities.imports import _IS_WINDOWS
label_desc: Use image node_id 5 for calling a global function with example usage: test_layout_leaf_node(find_ports_mock, flow) without return types