mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 23:11:44 +01:00
tests/repo: move .stages to unit
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
from dvc.ignore import DvcIgnore
|
||||
from dvc.main import main
|
||||
from dvc.repo import Repo
|
||||
from dvc.stage import Stage
|
||||
from tests.basic_env import TestDvcGit
|
||||
|
||||
|
||||
class TestIgnore(TestDvcGit):
|
||||
def _stage_name(self, file):
|
||||
return file + Stage.STAGE_FILE_SUFFIX
|
||||
|
||||
def test_should_not_gather_stage_files_from_ignored_dir(self):
|
||||
ret = main(["add", self.FOO, self.BAR, self.DATA, self.DATA_SUB])
|
||||
self.assertEqual(0, ret)
|
||||
|
||||
stages = self.dvc.stages
|
||||
self.assertEqual(4, len(stages))
|
||||
|
||||
self.create(DvcIgnore.DVCIGNORE_FILE, self.DATA_DIR)
|
||||
|
||||
self.dvc = Repo(self.dvc.root_dir)
|
||||
stages = self.dvc.stages
|
||||
self.assertEqual(2, len(stages))
|
||||
|
||||
stagenames = [s.relpath for s in stages]
|
||||
self.assertIn(self._stage_name(self.FOO), stagenames)
|
||||
self.assertIn(self._stage_name(self.BAR), stagenames)
|
||||
self.assertNotIn(self._stage_name(self.DATA), stagenames)
|
||||
self.assertNotIn(self._stage_name(self.DATA_SUB), stagenames)
|
||||
@@ -1,3 +1,4 @@
|
||||
from dvc.repo import Repo
|
||||
from dvc.scm.git import GitTree
|
||||
from dvc.system import System
|
||||
from dvc.utils.compat import fspath
|
||||
@@ -60,3 +61,16 @@ def test_collect(tmp_dir, scm, dvc, run_copy):
|
||||
|
||||
assert ["foo", "bar", "buzz"] == collect_outs("buzz.dvc", with_deps=True)
|
||||
assert ["buzz"] == collect_outs("buzz.dvc", with_deps=False)
|
||||
|
||||
|
||||
def test_stages(tmp_dir, dvc):
|
||||
tmp_dir.dvc_gen({"file": "a", "dir/file": "b", "dir/subdir/file": "c"})
|
||||
|
||||
def stages():
|
||||
return [stage.relpath for stage in Repo(tmp_dir).stages]
|
||||
|
||||
assert stages() == ["file.dvc", "dir/file.dvc", "dir/subdir/file.dvc"]
|
||||
|
||||
tmp_dir.gen(".dvcignore", "dir")
|
||||
|
||||
assert stages() == ["file.dvc"]
|
||||
|
||||
Reference in New Issue
Block a user