code: def test_list_all_apps_paginated(
      list_memberships: mock.MagicMock, list_instances: mock.MagicMock
  ):
      list_memberships.return_value = V1ListMembershipsResponse(
          memberships=[V1Membership(project_id="default-project")]
      )
      list_instances.side_effect = [
          V1ListLightningappInstancesResponse(
              lightningapps=[
                  Externalv1LightningappInstance(
                      name="test1",
                      spec=V1LightningappInstanceSpec(
                          desired_state=V1LightningappInstanceState.RUNNING
                      ),
                      status=V1LightningappInstanceStatus(
                          phase=V1LightningappInstanceState.RUNNING
                      ),
                  )
              ],
              next_page_token="page-2",
          ),
          V1ListLightningappInstancesResponse(
              lightningapps=[
                  Externalv1LightningappInstance(
                      name="test2",
                      spec=V1LightningappInstanceSpec(
                          desired_state=V1LightningappInstanceState.STOPPED
                      ),
                      status=V1LightningappInstanceStatus(
                          phase=V1LightningappInstanceState.RUNNING
                      ),
                  )
              ],
          ),
      ]
  
      cluster_manager = _AppManager()
      cluster_manager.list()
  
      list_memberships.assert_called_once()
      assert list_instances.mock_calls == [
          mock.call(
              project_id="default-project", limit=100, phase_in=[]
          ),
          mock.call(
              project_id="default-project",
              page_token="page-2",
              limit=100,
              phase_in=[],
          ),  # noqa: S106
      ]
  
file_path: pytorch-lightning/tests/tests_app/cli/test_cmd_apps.py
imports: from unittest import mock
  from unittest.mock import MagicMock
  import pytest
  from lightning.app.cli.cmd_apps import _AppList, _AppManager
  from lightning_cloud.openapi import Externalv1LightningappInstance, V1LightningappInstanceSpec, V1LightningappInstanceState, V1LightningappInstanceStatus, V1LightningworkState, V1ListLightningappInstancesResponse, V1ListLightningworkResponse, V1ListMembershipsResponse, V1Membership
  from rich.text import Text
label_desc: Use image node_id 2 for calling a global function with example usage: test_list_all_apps_paginated(list_memberships, list_instances) without return types