def test_file_to_directory(self): self.setup_file() dir_path = self.workspace.join('dst') os.makedirs(dir_path) ops.cp(self.path1, dir_path) path2 = os.path.join(dir_path, self.name1) self.check_same_file(self.path1, path2)
def test_recursive(self): self.setup_directory() path = self.workspace.join('dst') ops.cp(self.path1, path, recursive=False) self.assertFalse(os.path.exists(path)) ops.cp(self.path1, path, recursive=True) self.assertTrue(os.path.isdir(path))
def test_file_follow_links(self): self.setup_file() self.name3 = 'file3' self.name4 = 'file4' self.path3 = self.workspace.join(self.name3) self.path4 = self.workspace.join(self.name4) os.symlink(self.path1, self.path3) os.symlink(self.path2, self.path4) ops.cp(self.path3, self.path4, follow_links=True) self.check_same_file(self.path1, self.path2)
def test_directory(self): self.setup_directory() ops.cp(self.path1, self.path2) self.check_same_file(self.src_file_path1, self.dst_file_path1) self.check_same_file(self.src_file_path2, self.dst_file_path2) self.check_stat(self.path1, self.path2)
def test_error(self): # src path doesn't exist self.assertFalse(ops.cp('/tmp/ops-cp-error', '/tmp/ops-cp')) # invalid src or dst path ops.cp(True, False)
def test_file_to_file(self): self.setup_file() ops.cp(self.path1, self.path2) self.check_same_file(self.path1, self.path2)