code: def test_build_startup_url_and_app_root():
      from dtale.app import build_startup_url_and_app_root
  
      with ExitStack() as stack:
          stack.enter_context(
              mock.patch("dtale.app.JUPYTER_SERVER_PROXY", True)
          )
          stack.enter_context(
              mock.patch("dtale.app.ACTIVE_PORT", 40000)
          )
          stack.enter_context(
              mock.patch("dtale.app.ACTIVE_HOST", "localhost")
          )
          url, app_root = build_startup_url_and_app_root()
  
          assert url == "/user/{}/proxy/40000".format(getpass.getuser())
          assert app_root == "/user/{}/proxy/40000".format(
              getpass.getuser()
          )
          url, app_root = build_startup_url_and_app_root("/test_route/")
          assert url == "/test_route/40000"
          assert app_root == "/test_route/40000"
  
          os.environ["JUPYTERHUB_SERVICE_PREFIX"] = "/user/foo"
          url, app_root = build_startup_url_and_app_root()
          assert url == "/user/foo/proxy/40000"
          assert app_root == "/user/foo/proxy/40000"
  
          del os.environ["JUPYTERHUB_SERVICE_PREFIX"]
  
      with ExitStack() as stack:
          stack.enter_context(
              mock.patch("dtale.app.JUPYTER_SERVER_PROXY", False)
          )
          stack.enter_context(
              mock.patch("dtale.app.ACTIVE_PORT", 40000)
          )
          stack.enter_context(
              mock.patch("dtale.app.ACTIVE_HOST", "localhost")
          )
          url, app_root = build_startup_url_and_app_root()
          assert url == "http://localhost:40000"
          assert app_root is None
          url, app_root = build_startup_url_and_app_root("/test_route/")
          assert url == "http:/localhost:40000/test_route/"
          assert app_root == "/test_route/"
  
imports: import getpass
  from collections import namedtuple
  from flask import Flask
  import mock
  import numpy
  import os
  import pandas
  import pytest
  from tests import ExitStack, pdt
label_desc: Use image node_id 8 for calling a global function with example usage: test_build_startup_url_and_app_root() without return types