mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
* wip - pull is working * use fetch instead of reproduce * test pull and fetch * style changes * fetch: catch config error on fetch instead of get_remote * output: remove unused guard clause * fetch: define a more specific error instead of ConfigError * fetch: display number of errors correctly * exceptions: remove "Failed" prefix to download/upload * fetch: catch other exceptions that might halt the download * fetch: log catched exceptions * fetch: reformat exception Co-Authored-By: Ruslan Kuprieiev <[email protected]> * fix formatting
82 lines
1.9 KiB
Python
82 lines
1.9 KiB
Python
import os
|
|
import filecmp
|
|
import shutil
|
|
|
|
import pytest
|
|
from tests.utils import trees_equal
|
|
|
|
from dvc.stage import Stage
|
|
from dvc.exceptions import DownloadError
|
|
|
|
|
|
def test_import(repo_dir, git, dvc_repo, erepo):
|
|
src = erepo.FOO
|
|
dst = erepo.FOO + "_imported"
|
|
|
|
dvc_repo.imp(erepo.root_dir, src, dst)
|
|
|
|
assert os.path.exists(dst)
|
|
assert os.path.isfile(dst)
|
|
assert filecmp.cmp(repo_dir.FOO, dst, shallow=False)
|
|
assert git.git.check_ignore(dst)
|
|
|
|
|
|
def test_import_dir(repo_dir, git, dvc_repo, erepo):
|
|
src = erepo.DATA_DIR
|
|
dst = erepo.DATA_DIR + "_imported"
|
|
|
|
dvc_repo.imp(erepo.root_dir, src, dst)
|
|
|
|
assert os.path.exists(dst)
|
|
assert os.path.isdir(dst)
|
|
trees_equal(src, dst)
|
|
assert git.git.check_ignore(dst)
|
|
|
|
|
|
def test_import_rev(repo_dir, git, dvc_repo, erepo):
|
|
src = "version"
|
|
dst = src
|
|
|
|
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"
|
|
assert git.git.check_ignore(dst)
|
|
|
|
|
|
def test_pull_imported_stage(dvc_repo, erepo):
|
|
src = erepo.FOO
|
|
dst = erepo.FOO + "_imported"
|
|
|
|
dvc_repo.imp(erepo.root_dir, src, dst)
|
|
|
|
dst_stage = Stage.load(dvc_repo, "foo_imported.dvc")
|
|
dst_cache = dst_stage.outs[0].cache_path
|
|
|
|
os.remove(dst)
|
|
os.remove(dst_cache)
|
|
|
|
dvc_repo.pull(["foo_imported.dvc"])
|
|
|
|
assert os.path.isfile(dst)
|
|
assert os.path.isfile(dst_cache)
|
|
|
|
|
|
def test_download_error_pulling_imported_stage(dvc_repo, erepo):
|
|
src = erepo.FOO
|
|
dst = erepo.FOO + "_imported"
|
|
|
|
dvc_repo.imp(erepo.root_dir, src, dst)
|
|
|
|
dst_stage = Stage.load(dvc_repo, "foo_imported.dvc")
|
|
dst_cache = dst_stage.outs[0].cache_path
|
|
|
|
shutil.rmtree(erepo.root_dir)
|
|
os.remove(dst)
|
|
os.remove(dst_cache)
|
|
|
|
with pytest.raises(DownloadError):
|
|
dvc_repo.pull(["foo_imported.dvc"])
|