MCPcopy
hub / github.com/treeverse/dvc / test_foreach_data_from_nested_vars

Function test_foreach_data_from_nested_vars

tests/func/parsing/test_foreach.py:169–180  ·  view source on GitHub ↗
(tmp_dir, dvc)

Source from the content-addressed store, hash-verified

167
168
169def test_foreach_data_from_nested_vars(tmp_dir, dvc):
170 vars_ = {"models": {"lst": [{"thresh": 10}, {"thresh": 15}]}}
171 resolver = DataResolver(dvc, tmp_dir.fs_path, {"vars": [vars_]})
172 data = {"foreach": "${models.lst}", "do": {"cmd": "echo ${item.thresh}"}}
173 definition = ForeachDefinition(resolver, resolver.context, "build", data)
174
175 assert definition.resolve_all() == {
176 "build@0": {"cmd": "echo 10"},
177 "build@1": {"cmd": "echo 15"},
178 }
179 assert resolver.context == vars_
180 assert not any(item for item in resolver.tracked_vars.values())
181
182
183def test_foreach_partial_interpolations(tmp_dir, dvc):

Callers

nothing calls this directly

Calls 3

resolve_allMethod · 0.95
DataResolverClass · 0.90
ForeachDefinitionClass · 0.90

Tested by

no test coverage detected