code: def test_view(unittest):
      from dtale.views import build_dtypes_state
      import dtale.global_state as global_state
  
      global_state.clear_store()
      df = replacements_data()
      with app.test_client() as c:
          data = {c.port: df}
          dtypes = {c.port: build_dtypes_state(df)}
          build_data_inst(data)
          build_dtypes(dtypes)
          resp = c.get(
              "/dtale/build-replacement/{}".format(c.port),
              query_string=dict(
                  type="not_implemented",
                  name="test",
                  cfg=json.dumps({}),
              ),
          )
          response_data = resp.json
          assert (
              response_data["error"]
              == "'not_implemented' replacement not implemented yet!"
          )
  
          params = dict(
              type="value",
              col="e",
              name="a",
              cfg=json.dumps(
                  [dict(value="nan", type="raw", replace="for test")]
              ),
          )
          resp = c.get(
              "/dtale/build-replacement/{}".format(c.port),
              query_string=params,
          )
          response_data = resp.json
          assert (
              response_data["error"]
              == "A column named 'a' already exists!"
          )
  
          params = dict(
              type="value",
              col="e",
              name="e2",
              cfg=json.dumps(
                  [dict(value="nan", type="raw", replace="for test")]
              ),
          )
          c.get(
              "/dtale/build-replacement/{}".format(c.port),
              query_string=params,
          )
          unittest.assertEqual(
              list(data[c.port]["e2"].values), ["a", "for test", "b"]
          )
          dtypes = global_state.get_dtypes(c.port)
          assert dtypes[-1]["name"] == "e2"
          assert dtypes[-1]["dtype"] == "string" if PY3 else "mixed"
          assert not dtypes[-1]["hasMissing"]
  
          del params["name"]
          c.get(
              "/dtale/build-replacement/{}".format(c.port),
              query_string=params,
          )
          dtypes = global_state.get_dtypes(c.port)
          unittest.assertEqual(
              list(data[c.port]["e"].values), ["a", "for test", "b"]
          )
          e_dtype = next((d for d in dtypes if d["name"] == "e"))
          assert not e_dtype["hasMissing"]
  
file_path: dtale/tests/dtale/test_replacements.py
imports: import json
  import numpy
  import pandas
  import pytest
  import sklearn
  from pkg_resources import parse_version
  from six import PY3
  from dtale.column_replacements import ColumnReplacement
  from tests.dtale.test_views import app
  from tests.dtale import build_data_inst, build_dtypes
label_desc: Use image node_id 10 for calling a global function with example usage: test_view(unittest) without return types