diff --git a/tests/func/test_repo.py b/tests/func/test_repo.py deleted file mode 100644 index cbf454e99..000000000 --- a/tests/func/test_repo.py +++ /dev/null @@ -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) diff --git a/tests/unit/test_repo.py b/tests/unit/test_repo.py index 3e79a0776..aafec4de0 100644 --- a/tests/unit/test_repo.py +++ b/tests/unit/test_repo.py @@ -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"]