code: def test_web_upload(unittest):
      import dtale.global_state as global_state
  
      global_state.clear_store()
      global_state.set_app_settings(dict(enable_web_uploads=True))
      with build_app(url=URL).test_client() as c:
          with ExitStack() as stack:
              load_csv = stack.enter_context(
                  mock.patch(
                      "dtale.cli.loaders.csv_loader.loader_func",
                      mock.Mock(
                          return_value=pd.DataFrame(dict(a=[1], b=[2]))
                      ),
                  )
              )
              load_excel = stack.enter_context(
                  mock.patch(
                      "dtale.cli.loaders.excel_loader.load_file",
                      mock.Mock(
                          return_value={
                              "Sheet 1": pd.DataFrame(
                                  dict(a=[1], b=[2])
                              )
                          }
                      ),
                  )
              )
              load_json = stack.enter_context(
                  mock.patch(
                      "dtale.cli.loaders.json_loader.loader_func",
                      mock.Mock(
                          return_value=pd.DataFrame(dict(a=[1], b=[2]))
                      ),
                  )
              )
              params = {"type": "csv", "url": "http://test.com"}
              c.get("/dtale/web-upload", query_string=params)
              load_csv.assert_called_once()
              unittest.assertEqual(
                  load_csv.call_args[1],
                  {"path": "http://test.com", "proxy": None},
              )
              assert global_state.size() == 1
              load_csv.reset_mock()
  
              params = {"type": "tsv", "url": "http://test.com"}
              c.get("/dtale/web-upload", query_string=params)
              load_csv.assert_called_once()
              unittest.assertEqual(
                  load_csv.call_args[1],
                  {
                      "path": "http://test.com",
                      "proxy": None,
                      "delimiter": "\t",
                  },
              )
              assert global_state.size() == 2
  
              params = {
                  "type": "json",
                  "url": "http://test.com",
                  "proxy": "http://testproxy.com",
              }
              c.get("/dtale/web-upload", query_string=params)
              load_json.assert_called_once()
              unittest.assertEqual(
                  load_json.call_args[1],
                  {
                      "path": "http://test.com",
                      "proxy": "http://testproxy.com",
                  },
              )
              assert global_state.size() == 3
  
              params = {"type": "excel", "url": "http://test.com"}
              c.get("/dtale/web-upload", query_string=params)
              load_excel.assert_called_once()
              unittest.assertEqual(
                  load_excel.call_args[1],
                  {"path": "http://test.com", "proxy": None},
              )
              assert global_state.size() == 4
              global_state.clear_store()
              load_excel.reset_mock()
              load_excel.return_value = {
                  "Sheet 1": pd.DataFrame(dict(a=[1], b=[2])),
                  "Sheet 2": pd.DataFrame(dict(c=[1], d=[2])),
              }
              resp = c.get("/dtale/web-upload", query_string=params)
              sheets = resp.json["sheets"]
              assert len(sheets) == 2
              unittest.assertEqual(
                  sorted([s["name"] for s in sheets]),
                  ["Sheet 1", "Sheet 2"],
              )
  
              global_state.set_app_settings(
                  dict(enable_web_uploads=False)
              )
              resp = c.get("/dtale/web-upload", query_string=params)
              response_data = resp.get_json()
              assert not response_data["success"]
              assert response_data["error"] == (
                  "Web uploads not enabled! Web uploads are vulnerable to blind server side request forgery, please "
                  "only use in trusted environments."
              )
              global_state.set_app_settings(
                  dict(enable_web_uploads=True)
              )
  
file_path: dtale/tests/dtale/test_upload.py
imports: import os
  import mock
  import pandas
  import pytest
  from six import BytesIO, PY3
  from dtale.app import build_app
  from dtale.pandas_util import check_pandas_version
  from tests import ExitStack
  from tests.dtale import build_data_inst
label_desc: Use image node_id 3 for calling a global function with example usage: test_web_upload(unittest) without return types