code: def test_convert_paths_after_init():
      """Test that we can convert paths after the Flow/Work initialization, i.e., when the LightningApp is fully
      instantiated."""
  
      # TODO: Add a test case for the Lightning List and Dict containers
  
      class Flow1(EmptyFlow):
          def __init__(self):
              super().__init__()
              self.path1 = Path("a")
              self.path2 = Path("b")
  
      flow1 = Flow1()
      assert flow1._paths == {}
      _convert_paths_after_init(flow1)
      assert flow1._paths == {
          "path1": Path("a").to_dict(),
          "path2": Path("b").to_dict(),
      }
  
      class Work1(EmptyWork):
          def __init__(self):
              super().__init__()
              self.path3 = Path("c")
  
      class Flow2(EmptyFlow):
          def __init__(self):
              super().__init__()
              self.work1 = Work1()
              self.path4 = Path("d")
  
      flow2 = Flow2()
      assert flow2._paths == {}
      assert flow2.work1._paths == {}
      _convert_paths_after_init(flow2)
      assert flow2._paths == {"path4": Path("d").to_dict()}
      assert set(flow2.work1._paths.keys()) == {"path3"}
      assert flow2.work1._paths["path3"]["origin_name"] == "root.work1"
      assert (
          flow2.work1._paths["path3"]["consumer_name"] == "root.work1"
      )
  
file_path: pytorch-lightning/tests/tests_app/utilities/test_component.py
imports: import pytest
  from lightning.app.storage.path import Path
  from lightning.app.testing.helpers import EmptyFlow, EmptyWork
  from lightning.app.utilities.component import _context, _convert_paths_after_init, _get_context, _is_flow_context, _is_work_context, _set_context, _set_work_context
  from lightning.app.utilities.enum import ComponentContext
label_desc: Use image node_id 1 for calling a global function with example usage: test_convert_paths_after_init() without return types