code: def test_plots_templates(
      dvc, mocker, capsys, target, expected_out, expected_rtn
  ):
      t1 = mocker.Mock()
      t1.DEFAULT_NAME = "t1"
      t1.DEFAULT_CONTENT = "{'t1'}"
  
      t2 = mocker.Mock()
      t2.DEFAULT_NAME = "t2"
      t2.DEFAULT_CONTENT = "{'t2'}"
  
      mocker.patch("dvc_render.vega_templates.TEMPLATES", [t1, t2])
  
      arguments = ["plots", "templates"]
      if target:
          arguments += [target]
  
      cli_args = parse_args(arguments)
      assert cli_args.func == CmdPlotsTemplates
  
      cmd = cli_args.func(cli_args)
  
      rtn = cmd.run()
  
      out, _ = capsys.readouterr()
  
      assert out.strip() == expected_out
      assert rtn == expected_rtn
  
imports: import json
  import os
  import posixpath
  from pathlib import Path
  import pytest
  from funcy import set_in
  from dvc.cli import parse_args
  from dvc.commands.plots import CmdPlotsDiff, CmdPlotsShow, CmdPlotsTemplates
  from dvc.render.match import RendererWithErrors
  from dvc.utils.serialize import YAMLFileCorruptedError
label_desc: Use image node_id 12 for calling a global function with example usage: test_plots_templates(dvc, mocker, capsys, target, expected_out, expected_rtn) without return types