mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Merge pull request #3118 from efiop/2896-external-repo
tests: external_repo: convert to dir helpers
This commit is contained in:
@@ -4,21 +4,27 @@ from mock import patch
|
||||
|
||||
from dvc.external_repo import external_repo
|
||||
from dvc.scm.git import Git
|
||||
from dvc.compat import fspath
|
||||
from dvc.utils.fs import path_isin
|
||||
|
||||
|
||||
def test_external_repo(erepo):
|
||||
url = erepo.root_dir
|
||||
def test_external_repo(erepo_dir):
|
||||
with erepo_dir.chdir():
|
||||
with erepo_dir.branch("branch", new=True):
|
||||
erepo_dir.dvc_gen("file", "branch", commit="create file on branch")
|
||||
erepo_dir.dvc_gen("file", "master", commit="create file on master")
|
||||
|
||||
url = fspath(erepo_dir)
|
||||
# We will share cache dir, to fetch version file
|
||||
cache_dir = erepo.dvc.cache.local.cache_dir
|
||||
cache_dir = erepo_dir.dvc.cache.local.cache_dir
|
||||
|
||||
with patch.object(Git, "clone", wraps=Git.clone) as mock:
|
||||
with external_repo(url, cache_dir=cache_dir) as repo:
|
||||
with repo.open(os.path.join(repo.root_dir, "version")) as fd:
|
||||
with repo.open(os.path.join(repo.root_dir, "file")) as fd:
|
||||
assert fd.read() == "master"
|
||||
|
||||
with external_repo(url, rev="branch", cache_dir=cache_dir) as repo:
|
||||
with repo.open(os.path.join(repo.root_dir, "version")) as fd:
|
||||
with repo.open(os.path.join(repo.root_dir, "file")) as fd:
|
||||
assert fd.read() == "branch"
|
||||
|
||||
# Check cache_dir is unset
|
||||
|
||||
Reference in New Issue
Block a user