code: def test_merge(unittest):
      from dtale.views import build_dtypes_state
      import dtale.global_state as global_state
  
      global_state.clear_store()
  
      left = pd.DataFrame(
          {
              "key1": ["K0", "K0", "K1", "K2"],
              "key2": ["K0", "K1", "K0", "K1"],
              "A": ["A0", "A1", "A2", "A3"],
              "B": ["B0", "B1", "B2", "B3"],
          }
      )
      right = pd.DataFrame(
          {
              "key1": ["K0", "K1", "K1", "K2"],
              "key2": ["K0", "K0", "K0", "K0"],
              "C": ["C0", "C1", "C2", "C3"],
              "D": ["D0", "D1", "D2", "D3"],
          }
      )
      right2 = pd.DataFrame(
          {
              "key1": ["K0", "K1"],
              "key2": ["K0", "K0"],
              "E": ["E0", "E1"],
              "F": ["F0", "F1"],
          }
      )
      with app.test_client() as c:
          data = {"1": left, "2": right, "3": right2}
          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=[],
                  index=["key1", "key2"],
                  suffix="",
              ),
              dict(
                  dataId="2",
                  columns=[],
                  index=["key1", "key2"],
                  suffix="",
              ),
          ]
          config = dict(how="inner", sort=False, indicator=False)
          resp = c.post(
              "/dtale/merge",
              data=json.dumps(
                  dict(
                      action="merge",
                      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.columns),
              ["key1", "key2", "A", "B", "C", "D"],
          )
          assert len(final_df) == 3
  
          datasets[0]["columns"] = ["A"]
          datasets[1]["columns"] = ["C"]
          config["how"] = "left"
          config["indicator"] = True
          resp = c.post(
              "/dtale/merge",
              data=json.dumps(
                  dict(
                      action="merge",
                      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.columns),
              ["key1", "key2", "A", "C", "merge_1"],
          )
          unittest.assertEqual(
              list(final_df["merge_1"].values),
              ["both", "left_only", "both", "both", "left_only"],
          )
  
          datasets.append(
              dict(dataId="3", index=["key1", "key2"], suffix="3")
          )
          resp = c.post(
              "/dtale/merge",
              data=json.dumps(
                  dict(
                      action="merge",
                      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.columns),
              [
                  "key1",
                  "key2",
                  "A",
                  "C",
                  "merge_1",
                  "E",
                  "F",
                  "merge_2",
              ],
          )
          unittest.assertEqual(
              list(final_df["merge_2"].values),
              ["both", "left_only", "both", "both", "left_only"],
          )
  
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 1 for calling a global function with example usage: test_merge(unittest) without return types