Exemplo n.º 1
0
 def test_branch(self):
     scm = SCM(self._root_dir)
     scm.add([self.DATA_SUB_DIR])
     scm.commit("add data_dir/data_sub_dir/data_sub")
     tree = GitTree(self.git, "master")
     self.assertWalkEqual(
         tree.walk("."),
         [
             (self._root_dir, ["data_dir"], ["code.py"]),
             (join(self._root_dir, "data_dir"), ["data_sub_dir"], []),
             (
                 join(self._root_dir, "data_dir", "data_sub_dir"),
                 [],
                 ["data_sub"],
             ),
         ],
     )
     self.assertWalkEqual(
         tree.walk(join("data_dir", "data_sub_dir")),
         [(
             join(self._root_dir, "data_dir", "data_sub_dir"),
             [],
             ["data_sub"],
         )],
     )
Exemplo n.º 2
0
 def _check(self, branch, target, with_deps, expected):
     if branch:
         self.dvc.tree = GitTree(self.dvc.scm.git, branch)
     else:
         self.dvc.tree = WorkingTree()
     result = self.dvc.collect(target + ".dvc", with_deps=with_deps)
     self.assertEqual([[str(j) for j in i.outs] for i in result], expected)
     return result
Exemplo n.º 3
0
 def setUp(self):
     super().setUp()
     self.scm = SCM(self._root_dir)
     self.tree = GitTree(self.git, "master")
     self._pushd(self._root_dir)
Exemplo n.º 4
0
 def setUp(self):
     super(TestGitTree, self).setUp()
     self.scm = SCM(self._root_dir)
     self.tree = GitTree(self.git, "master")
Exemplo n.º 5
0
class TestGitTree(TestGit):
    def setUp(self):
        super(TestGitTree, self).setUp()
        self.scm = SCM(self._root_dir)
        self.tree = GitTree(self.git, "master")

    def test_open(self):
        self.scm.add([self.FOO, self.UNICODE, self.DATA_DIR])
        self.scm.commit("add")
        with self.tree.open(self.FOO) as fd:
            self.assertEqual(fd.read(), self.FOO_CONTENTS)
        with self.tree.open(self.UNICODE) as fd:
            self.assertEqual(fd.read(), self.UNICODE_CONTENTS)
        with self.assertRaises(IOError):
            self.tree.open("not-existing-file")
        with self.assertRaises(IOError):
            self.tree.open(self.DATA_DIR)

    def test_exists(self):
        self.assertFalse(self.tree.exists(self.FOO))
        self.assertFalse(self.tree.exists(self.UNICODE))
        self.assertFalse(self.tree.exists(self.DATA_DIR))
        self.scm.add([self.FOO, self.UNICODE, self.DATA])
        self.scm.commit("add")
        self.assertTrue(self.tree.exists(self.FOO))
        self.assertTrue(self.tree.exists(self.UNICODE))
        self.assertTrue(self.tree.exists(self.DATA_DIR))
        self.assertFalse(self.tree.exists("non-existing-file"))

    def test_isdir(self):
        self.scm.add([self.FOO, self.DATA_DIR])
        self.scm.commit("add")
        self.assertTrue(self.tree.isdir(self.DATA_DIR))
        self.assertFalse(self.tree.isdir(self.FOO))
        self.assertFalse(self.tree.isdir("non-existing-file"))

    def test_isfile(self):
        self.scm.add([self.FOO, self.DATA_DIR])
        self.scm.commit("add")
        self.assertTrue(self.tree.isfile(self.FOO))
        self.assertFalse(self.tree.isfile(self.DATA_DIR))
        self.assertFalse(self.tree.isfile("not-existing-file"))