Ejemplo n.º 1
0
    def test_clone(self):
        def addFiles():
            os.mkdir(dirn[0])
            f = open(os.path.join(dirn[0], ".gitignore"), "w")
            f.write("test")
            f.close()
            os.mkdir(os.path.join(dirn[0], "sub"))
            f = open(os.path.join(dirn[0], "sub", "abacaba"), "w")
            f.write("release")
            f.close()

        def gitCommand(folder, command_line):  # "folder" is subdirectory
            os.chdir(folder)
            try:
                out = subprocess.check_output(command_line)
            finally:
                os.chdir("..")
            return out

        addFiles()
        gitCommand(dirn[0], "git init")
        gitCommand(dirn[0], "git add .")
        gitCommand(dirn[0], "git commit -m 'Init'")
        clone_repository(dirn[0], dirn[1])

        out = [""] * 2
        command_line = "git ls-tree -r --name-only --full-tree master"
        for i, dirname in enumerate(dirn):
            out[i] = gitCommand(dirn[1], command_line)
        self.assertEqual(out[0], out[1])
Ejemplo n.º 2
0
 def test_dir_exists(self):
     for dirname in dirn:
         os.mkdir(dirname)
     with self.assertRaises(OSError):
         clone_repository(dirn[0], dirn[1])