code: def test_foreach_data_is_only_resolved_once(tmp_dir, dvc, mocker):
      context = Context(models=["foo", "bar", "baz"])
      data = {"foreach": "${models}", "do": {}}
      definition = ForeachDefinition(
          DataResolver(dvc, tmp_dir.fs_path, {}), context, "build", data
      )
      mock = mocker.spy(definition, "_resolve_foreach_data")
  
      definition.resolve_all()
  
      mock.assert_called_once_with()
  
imports: import os
  import pytest
  from dvc.parsing import DEFAULT_PARAMS_FILE, DataResolver, ForeachDefinition
  from dvc.parsing.context import Context
label_desc: Use image node_id 18 for calling a global function with example usage: test_foreach_data_is_only_resolved_once(tmp_dir, dvc, mocker) without return types