code: def test_stack(unittest):
      from dtale.views import build_dtypes_state
      import dtale.global_state as global_state
  
      global_state.clear_store()
      df1 = pd.DataFrame(
          {
              "A": ["A0", "A1"],
              "B": ["B0", "B1"],
              "C": ["C0", "C1"],
              "D": ["D0", "D1"],
          }
      )
      df2 = pd.DataFrame(
          {
              "A": ["A2", "A3"],
              "B": ["B3", "B3"],
              "C": ["C3", "C3"],
              "D": ["D3", "D3"],
          }
      )
  
      with app.test_client() as c:
          data = {"1": df1, "2": df2}
          dtypes = {k: build_dtypes_state(v) for k, v in data.items()}
          settings = {k: {} for k in data.keys()}
          build_data_inst(data)
          build_dtypes(dtypes)
          build_settings(settings)
          datasets = [
              dict(dataId="1", columns=[]),
              dict(dataId="2", columns=[]),
          ]
          config = dict(ignore_index=False)
          resp = c.post(
              "/dtale/merge",
              data=json.dumps(
                  dict(
                      action="stack",
                      config=json.dumps(config),
                      datasets=json.dumps(datasets),
                  )
              ),
              content_type="application/json",
          )
          assert resp.status_code == 200
          final_df = global_state.get_data(resp.json["data_id"])
          unittest.assertEqual(
              list(final_df["A"].values), ["A0", "A1", "A2", "A3"]
          )
          unittest.assertEqual(
              list(final_df["index"].values), [0, 1, 0, 1]
          )
  
          config["ignoreIndex"] = True
          resp = c.post(
              "/dtale/merge",
              data=json.dumps(
                  dict(
                      action="stack",
                      config=json.dumps(config),
                      datasets=json.dumps(datasets),
                  )
              ),
              content_type="application/json",
          )
          assert resp.status_code == 200
          final_df = global_state.get_data(resp.json["data_id"])
          assert "index" not in final_df.columns
          unittest.assertEqual(
              list(final_df["A"].values), ["A0", "A1", "A2", "A3"]
          )
  
imports: import json
  import pandas
  import pytest
  from tests.dtale.test_views import app
  from tests.dtale import build_data_inst, build_settings, build_dtypes
label_desc: Use image node_id 2 for calling a global function with example usage: test_stack(unittest) without return types