fix tests

This commit is contained in:
Mr. Outis
2019-09-06 11:32:31 -05:00
parent 38d4cbf5c1
commit 6eb26de856
3 changed files with 17 additions and 11 deletions
+1 -2
View File
@@ -7,7 +7,6 @@ import os
import stat
import errno
from shortuuid import uuid
import shutil
import logging
from functools import partial
@@ -172,7 +171,7 @@ class RemoteLOCAL(RemoteBASE):
move(from_info, to_info, mode=mode)
def copy(self, from_info, to_info):
shutil.copyfile(from_info.fspath, to_info.fspath)
System.copy(from_info, to_info)
def symlink(self, from_info, to_info):
System.symlink(from_info, to_info)
+6
View File
@@ -4,6 +4,7 @@ from dvc.utils.compat import str, open, fspath
import os
import errno
import shutil
class System(object):
@@ -11,6 +12,11 @@ class System(object):
def is_unix():
return os.name != "nt"
@staticmethod
def copy(src, dest):
src, dest = fspath(src), fspath(dest)
return shutil.copyfile(src, dest)
@staticmethod
def hardlink(source, link_name):
import ctypes
+10 -9
View File
@@ -563,12 +563,12 @@ def test_should_not_checkout_when_adding_cached_copy(repo_dir, dvc_repo):
shutil.copy(repo_dir.BAR, repo_dir.FOO)
copy_spy = spy(shutil.copyfile)
copy_spy = spy(dvc_repo.cache.local.copy)
RemoteLOCAL.CACHE_TYPE_MAP["copy"] = copy_spy
dvc_repo.add(repo_dir.FOO)
with patch.object(dvc_repo.cache.local, "copy", copy_spy):
dvc_repo.add(repo_dir.FOO)
assert copy_spy.mock.call_count == 0
assert copy_spy.mock.call_count == 0
@pytest.mark.parametrize(
@@ -583,13 +583,13 @@ def test_should_not_checkout_when_adding_cached_copy(repo_dir, dvc_repo):
def test_should_relink_on_repeated_add(
link, new_link, link_test_func, repo_dir, dvc_repo
):
dvc_repo.cache.local.cache_types = [link]
dvc_repo.config.set("cache", "type", link)
dvc_repo.add(repo_dir.FOO)
dvc_repo.add(repo_dir.BAR)
os.remove(repo_dir.FOO)
RemoteLOCAL.CACHE_TYPE_MAP[link](repo_dir.BAR, repo_dir.FOO)
getattr(dvc_repo.cache.local, link)(repo_dir.BAR, repo_dir.FOO)
dvc_repo.cache.local.cache_types = [new_link]
@@ -613,10 +613,11 @@ def test_should_relink_single_file_in_dir(link, link_func, dvc_repo, repo_dir):
dvc_repo.unprotect(repo_dir.DATA_SUB)
link_spy = spy(link_func)
RemoteLOCAL.CACHE_TYPE_MAP[link] = link_spy
dvc_repo.add(repo_dir.DATA_DIR)
assert link_spy.mock.call_count == 1
with patch.object(dvc_repo.cache.local, link, link_spy):
dvc_repo.add(repo_dir.DATA_DIR)
assert link_spy.mock.call_count == 1
@pytest.mark.parametrize("link", ["hardlink", "symlink", "copy"])