code: def test_dag(tmp_dir, dvc, mocker, fmt, formatter):
      from dvc.commands import dag
  
      tmp_dir.dvc_gen("foo", "foo")
  
      args = ["dag", "--full", "foo.dvc"]
      if fmt:
          args.append(fmt)
      cli_args = parse_args(args)
      assert cli_args.func == CmdDAG
  
      fmt_func = mocker.spy(dag, formatter)
  
      cmd = cli_args.func(cli_args)
  
      mocker.patch(
          "dvc.commands.dag._build", return_value=dvc.index.graph
      )
  
      assert cmd.run() == 0
  
      assert fmt_func.called
  
file_path: dvc/tests/unit/command/test_dag.py
imports: import networkx
  import pytest
  from dvc.cli import main, parse_args
  from dvc.commands.dag import CmdDAG, _build, _show_ascii, _show_dot, _show_mermaid
label_desc: Use image node_id 1 for calling a global function with example usage: test_dag(tmp_dir, dvc, mocker, fmt, formatter) without return types