예제 #1
0
    def testUpdate(self):
        source = file(self.file1, "w")
        source.write("source")
        source.close()
        sourceMtime = os.stat(self.file1).st_mtime
        # make source file older
        os.utime(self.file1, (sourceMtime - 20000000, sourceMtime - 20000000))

        targetPath = os.path.join(self.dir2, "file1")
        file(targetPath, "w")

        self.copier.parse_args(["--update-only", self.file1, self.dir2])
        self.copier.do_work()

        target = file(targetPath, "r")
        targetContent = target.read()
        shutil.rmtree(targetPath, True)

        self.failIf(targetContent == "source",
                    "Newer target file was overwritten!")

        copier = CopyTool()
        copier.parse_args([self.file1, self.dir2])
        copier.do_work()

        target = file(targetPath, "r")
        targetContent = target.read()
        shutil.rmtree(targetPath, True)

        self.failIf(targetContent != "source",
                    "Newer target file was not overwritten!")
예제 #2
0
 def testExclude(self):
     self.copier.parse_args(["-x", "dir1", self.dir1, self.dir2])
     self.copier.do_work()
     self.failIf(os.path.exists(os.path.join(self.dir2, "dir1")),
                 "Excluded directory was copied!")
     copier = CopyTool()
     copier.parse_args(["-x", "file1", self.dir1, self.dir2])
     copier.do_work()
     self.failIf(os.path.exists(os.path.join(self.dir2, "file1")),
                 "Excluded file was copied!")
예제 #3
0
 def setUp(self):
     self.copier = CopyTool()
     self.tempDir = tempfile.mkdtemp()
     self.file1 = os.path.join(self.tempDir, "file1")
     file(self.file1, "w")
     self.file2 = os.path.join(self.tempDir, "file2")
     file(self.file2, "w")
     self.dir1 = os.path.join(self.tempDir, "dir1")
     os.mkdir(self.dir1)
     self.dir2 = os.path.join(self.tempDir, "dir2")
     os.mkdir(self.dir2)