mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
This will speed up cache collection and then run single cloud op for all collected cache. Fixes #2308.
70 lines
1.6 KiB
Python
70 lines
1.6 KiB
Python
import os
|
|
import shutil
|
|
import filecmp
|
|
|
|
from dvc.repo import Repo
|
|
|
|
|
|
def test_update_import(dvc_repo, erepo):
|
|
src = "version"
|
|
dst = src
|
|
|
|
stage = dvc_repo.imp(erepo.root_dir, src, dst, rev="branch")
|
|
|
|
assert os.path.exists(dst)
|
|
assert os.path.isfile(dst)
|
|
with open(dst, "r+") as fobj:
|
|
assert fobj.read() == "branch"
|
|
|
|
# update data
|
|
repo = Repo(erepo.root_dir)
|
|
|
|
saved_dir = os.getcwd()
|
|
os.chdir(erepo.root_dir)
|
|
|
|
repo.scm.checkout("branch")
|
|
os.unlink("version")
|
|
erepo.create("version", "updated")
|
|
repo.add("version")
|
|
repo.scm.add([".gitignore", "version.dvc"])
|
|
repo.scm.commit("updated")
|
|
repo.scm.checkout("master")
|
|
|
|
repo.scm.git.close()
|
|
|
|
os.chdir(saved_dir)
|
|
|
|
assert dvc_repo.status([stage.path]) == {}
|
|
dvc_repo.update(stage.path)
|
|
assert dvc_repo.status([stage.path]) == {}
|
|
|
|
assert os.path.exists(dst)
|
|
assert os.path.isfile(dst)
|
|
with open(dst, "r+") as fobj:
|
|
assert fobj.read() == "updated"
|
|
|
|
|
|
def test_update_import_url(repo_dir, dvc_repo):
|
|
src = "file"
|
|
dst = src + "_imported"
|
|
|
|
shutil.copyfile(repo_dir.FOO, src)
|
|
|
|
stage = dvc_repo.imp_url(src, dst)
|
|
|
|
assert os.path.exists(dst)
|
|
assert os.path.isfile(dst)
|
|
assert filecmp.cmp(src, dst, shallow=False)
|
|
|
|
# update data
|
|
os.unlink(src)
|
|
shutil.copyfile(repo_dir.BAR, src)
|
|
|
|
assert dvc_repo.status([stage.path]) == {}
|
|
dvc_repo.update(stage.path)
|
|
assert dvc_repo.status([stage.path]) == {}
|
|
|
|
assert os.path.exists(dst)
|
|
assert os.path.isfile(dst)
|
|
assert filecmp.cmp(src, dst, shallow=False)
|