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

Function test_update_rev

tests/func/test_update.py:248–279  ·  view source on GitHub ↗
(tmp_dir, dvc, scm, git_dir)

Source from the content-addressed store, hash-verified

246
247
248def test_update_rev(tmp_dir, dvc, scm, git_dir):
249 with git_dir.chdir():
250 git_dir.scm_gen({"foo": "foo"}, commit="first")
251
252 dvc.imp(os.fspath(git_dir), "foo")
253 assert (tmp_dir / "foo.dvc").exists()
254
255 with git_dir.chdir(), git_dir.branch("branch1", new=True):
256 git_dir.scm_gen({"foo": "foobar"}, commit="branch1 commit")
257 branch1_head = git_dir.scm.get_rev()
258
259 with git_dir.chdir(), git_dir.branch("branch2", new=True):
260 git_dir.scm_gen({"foo": "foobar foo"}, commit="branch2 commit")
261 branch2_head = git_dir.scm.get_rev()
262
263 stage = dvc.update(["foo.dvc"], rev="branch1")[0]
264 assert stage.deps[0].def_repo == {
265 "url": os.fspath(git_dir),
266 "rev": "branch1",
267 "rev_lock": branch1_head,
268 }
269 with open(tmp_dir / "foo", encoding="utf-8") as f:
270 assert f.read() == "foobar"
271
272 stage = dvc.update(["foo.dvc"], rev="branch2")[0]
273 assert stage.deps[0].def_repo == {
274 "url": os.fspath(git_dir),
275 "rev": "branch2",
276 "rev_lock": branch2_head,
277 }
278 with open(tmp_dir / "foo", encoding="utf-8") as f:
279 assert f.read() == "foobar foo"
280
281
282def test_update_recursive(tmp_dir, dvc, erepo_dir):

Callers

nothing calls this directly

Calls 9

openFunction · 0.85
scm_genMethod · 0.80
chdirMethod · 0.45
fspathMethod · 0.45
existsMethod · 0.45
branchMethod · 0.45
get_revMethod · 0.45
updateMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected