mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 15:28:28 +01:00
fixup! get: copy regular files
This commit is contained in:
+10
-3
@@ -41,14 +41,19 @@ class TestDirFixture(object):
|
||||
# in tests, we replace foo with bar, so we need to make sure that when we
|
||||
# modify a file in our tests, its content length changes.
|
||||
BAR_CONTENTS = BAR + "r"
|
||||
CODE_DIR = "code"
|
||||
CODE = "code/code.py"
|
||||
CODE = "code.py"
|
||||
CODE_CONTENTS = (
|
||||
"import sys\nimport shutil\n"
|
||||
"shutil.copyfile(sys.argv[1], sys.argv[2])"
|
||||
)
|
||||
UNICODE = "тест"
|
||||
UNICODE_CONTENTS = "проверка"
|
||||
REGULAR_DIR = "lib"
|
||||
REGULAR_FILE = os.path.join(REGULAR_DIR, "file.txt")
|
||||
REGULAR_FILE_CONTENTS = """
|
||||
A file used to test retrieval of regular files tracked by git that
|
||||
are not stored in a dvc remote backend.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
root_dir = self.mkdtemp()
|
||||
@@ -91,13 +96,14 @@ class TestDirFixture(object):
|
||||
self._pushd(self._root_dir)
|
||||
self.create(self.FOO, self.FOO_CONTENTS)
|
||||
self.create(self.BAR, self.BAR_CONTENTS)
|
||||
os.mkdir(self.CODE_DIR)
|
||||
self.create(self.CODE, self.CODE_CONTENTS)
|
||||
os.mkdir(self.DATA_DIR)
|
||||
os.mkdir(self.DATA_SUB_DIR)
|
||||
self.create(self.DATA, self.DATA_CONTENTS)
|
||||
self.create(self.DATA_SUB, self.DATA_SUB_CONTENTS)
|
||||
self.create(self.UNICODE, self.UNICODE_CONTENTS)
|
||||
os.mkdir(self.REGULAR_DIR)
|
||||
self.create(self.REGULAR_FILE, self.REGULAR_FILE_CONTENTS)
|
||||
|
||||
def tearDown(self):
|
||||
self._popd()
|
||||
@@ -139,6 +145,7 @@ class TestGitFixture(TestDirFixture):
|
||||
raise
|
||||
|
||||
self.git.index.add([self.CODE])
|
||||
self.git.index.add([self.REGULAR_DIR])
|
||||
self.git.index.commit("add code")
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -39,19 +39,19 @@ def test_get_repo_dir(erepo):
|
||||
|
||||
|
||||
def test_get_regular_file(repo_dir, erepo):
|
||||
src = erepo.CODE
|
||||
dst = erepo.CODE
|
||||
src = erepo.REGULAR_FILE
|
||||
dst = erepo.REGULAR_FILE + "_imported"
|
||||
|
||||
Repo.get(erepo.root_dir, src, dst)
|
||||
|
||||
assert os.path.exists(dst)
|
||||
assert os.path.isfile(dst)
|
||||
assert filecmp.cmp(repo_dir.CODE, dst, shallow=False)
|
||||
assert filecmp.cmp(src, dst, shallow=False)
|
||||
|
||||
|
||||
def test_get_regular_dir(repo_dir, erepo):
|
||||
src = erepo.CODE_DIR
|
||||
dst = erepo.CODE_DIR
|
||||
src = erepo.REGULAR_DIR
|
||||
dst = erepo.REGULAR_DIR + "_imported"
|
||||
|
||||
Repo.get(erepo.root_dir, src, dst)
|
||||
|
||||
|
||||
@@ -738,9 +738,9 @@ class TestCmdReproChdirCwdBackwardCompatible(TestDvc):
|
||||
os.mkdir(dname)
|
||||
foo = os.path.join(dname, self.FOO)
|
||||
bar = os.path.join(dname, self.BAR)
|
||||
code_dir = os.path.join(dname, self.CODE_DIR)
|
||||
code = os.path.join(dname, self.CODE)
|
||||
shutil.copyfile(self.FOO, foo)
|
||||
shutil.copytree(self.CODE_DIR, code_dir)
|
||||
shutil.copyfile(self.CODE, code)
|
||||
|
||||
ret = main(
|
||||
[
|
||||
@@ -776,9 +776,9 @@ class TestCmdReproChdir(TestDvc):
|
||||
os.mkdir(dname)
|
||||
foo = os.path.join(dname, self.FOO)
|
||||
bar = os.path.join(dname, self.BAR)
|
||||
code_dir = os.path.join(dname, self.CODE_DIR)
|
||||
code = os.path.join(dname, self.CODE)
|
||||
shutil.copyfile(self.FOO, foo)
|
||||
shutil.copytree(self.CODE_DIR, code_dir)
|
||||
shutil.copyfile(self.CODE, code)
|
||||
|
||||
ret = main(
|
||||
[
|
||||
|
||||
@@ -115,9 +115,10 @@ class TestWalkInNoSCM(AssertWalkEqualMixin, TestDir):
|
||||
[
|
||||
(
|
||||
self._root_dir,
|
||||
["data_dir"],
|
||||
["lib", "data_dir"],
|
||||
["code.py", "bar", "тест", "foo"],
|
||||
),
|
||||
(join(self._root_dir, "lib"), [], ["file.txt"]),
|
||||
(join(self._root_dir, "data_dir"), ["data_sub_dir"], ["data"]),
|
||||
(
|
||||
join(self._root_dir, "data_dir", "data_sub_dir"),
|
||||
@@ -151,9 +152,10 @@ class TestWalkInGit(AssertWalkEqualMixin, TestGit):
|
||||
[
|
||||
(
|
||||
self._root_dir,
|
||||
["data_dir"],
|
||||
["lib", "data_dir"],
|
||||
["bar", "тест", "code.py", "foo"],
|
||||
),
|
||||
(join(self._root_dir, "lib"), [], ["file.txt"]),
|
||||
(join(self._root_dir, "data_dir"), ["data_sub_dir"], ["data"]),
|
||||
(
|
||||
join(self._root_dir, "data_dir", "data_sub_dir"),
|
||||
@@ -181,13 +183,14 @@ class TestWalkInGit(AssertWalkEqualMixin, TestGit):
|
||||
self.assertWalkEqual(
|
||||
tree.walk("."),
|
||||
[
|
||||
(self._root_dir, ["data_dir"], ["code.py"]),
|
||||
(self._root_dir, ["data_dir", "lib"], ["code.py"]),
|
||||
(join(self._root_dir, "data_dir"), ["data_sub_dir"], []),
|
||||
(
|
||||
join(self._root_dir, "data_dir", "data_sub_dir"),
|
||||
[],
|
||||
["data_sub"],
|
||||
),
|
||||
(join(self._root_dir, "lib"), [], ["file.txt"]),
|
||||
],
|
||||
)
|
||||
self.assertWalkEqual(
|
||||
|
||||
Reference in New Issue
Block a user