test: move corrupted hardlink cache test test_repro -> test_run

This commit is contained in:
pared
2019-04-15 12:55:50 +02:00
parent 9049475412
commit 074b6eaa9e
2 changed files with 31 additions and 29 deletions
-29
View File
@@ -854,30 +854,6 @@ class TestReproExternalBase(TestDvc):
mock_download.assert_not_called()
mock_checkout.assert_called_once()
def corrupted_cache(self):
os.unlink("bar.dvc")
stage = self.dvc.run(
deps=[self.FOO], outs=[self.BAR], cmd="echo bar > bar"
)
with open(self.BAR, "w") as fd:
fd.write("corrupting the cache")
patch_checkout = patch.object(
stage.outs[0], "checkout", wraps=stage.outs[0].checkout
)
patch_run = patch.object(stage, "_run", wraps=stage._run)
with self.dvc.state:
with patch_checkout as mock_checkout:
with patch_run as mock_run:
stage.run()
mock_run.assert_called_once()
mock_checkout.assert_not_called()
@patch("dvc.prompt.confirm", return_value=True)
def test(self, mock_prompt):
if not self.should_test():
@@ -909,9 +885,6 @@ class TestReproExternalBase(TestDvc):
ret = main(["remote", "modify", remote_name, "type", "hardlink"])
self.assertEqual(ret, 0)
ret = main(["config", "cache.type", "hardlink"])
self.assertEqual(0, ret)
self.dvc = DvcRepo(".")
foo_key = remote_key + self.sep + self.FOO
@@ -980,8 +953,6 @@ class TestReproExternalBase(TestDvc):
self.dvc.checkout(cmd_stage.path, force=True)
self.assertEqual(self.dvc.status(cmd_stage.path), {})
self.corrupted_cache()
class TestReproExternalS3(TestReproExternalBase):
def should_test(self):
+31
View File
@@ -9,6 +9,7 @@ import yaml
from dvc.main import main
from dvc.output import OutputBase
from dvc.repo import Repo as DvcRepo
from dvc.utils import file_md5, load_stage_file
from dvc.system import System
from dvc.stage import Stage, StagePathNotFoundError, StagePathNotDirectoryError
@@ -920,3 +921,33 @@ class TestNewRunShouldNotRemoveOutsOnPersist(TestRerunWithSameOutputs):
@property
def _outs_command(self):
return "--outs-persist"
class TestShouldNotCheckoutUponCorruptedLocalHardlinkCache(TestDvc):
def setUp(self):
super(
TestShouldNotCheckoutUponCorruptedLocalHardlinkCache, self
).setUp()
ret = main(["config", "cache.type", "hardlink"])
self.assertEqual(ret, 0)
self.dvc = DvcRepo(".")
def test(self):
cmd = "cp {} {}".format(self.FOO, self.BAR)
stage = self.dvc.run(deps=[self.FOO], outs=[self.BAR], cmd=cmd)
with open(self.BAR, "w") as fd:
fd.write("corrupting the output cache")
patch_checkout = mock.patch.object(
stage.outs[0], "checkout", wraps=stage.outs[0].checkout
)
patch_run = mock.patch.object(stage, "_run", wraps=stage._run)
with self.dvc.state:
with patch_checkout as mock_checkout:
with patch_run as mock_run:
stage.run()
mock_run.assert_called_once()
mock_checkout.assert_not_called()