code: def test_date_freq_handler():
      df = pd.DataFrame(
          dict(date=pd.date_range("20200101", "20200131"))
      )
      handler = chart_utils.date_freq_handler(df)
      s = handler(build_col_def("WD"))
      assert s[0].values[0] == 2
      s = handler(build_col_def("H2"))
      assert s[0].values[0] == 0
      s = handler(build_col_def("D"))
      assert s[0].dt.strftime("%Y%m%d").values[0] == "20200101"
      s = handler(build_col_def("M"))
      assert s[0].dt.strftime("%Y%m%d").values[0] == "20200131"
  
file_path: dtale/tests/dtale/test_charts.py
imports: import pandas
  import pytest
  import dtale.charts.utils
  from dtale.constants import CHART_JOINER_CHAR
label_desc: Use image node_id 2 for calling a global function with example usage: test_date_freq_handler() without return types