def test_no_move_outside_root(self): self.setContents("file1", "hello world") trn = FSTransaction(self.testdir) trn.move(self.path("file1"), "file2") trn.commit() self.assertContents("file2", "hello world") trn = FSTransaction(self.testdir) self.assertRaises(ValueError, trn.move, self.path("file2"), "../file1") trn.abort()
def test_remove_abort(self): self.setContents("dir1/file1", "hello there world") trn = FSTransaction() trn.remove(self.path("dir1/file1")) self.assertTrue(os.path.exists(self.path("dir1/file1"))) trn.abort() self.assertTrue(os.path.exists(self.path("dir1/file1"))) trn = FSTransaction() trn.remove(self.path("dir1")) trn.abort() self.assertTrue(os.path.exists(self.path("dir1/file1"))) trn = FSTransaction() trn.remove(self.path("dir1")) trn.commit() self.assertFalse(os.path.exists(self.path("dir1")))