예제 #1
0
파일: test_esky.py 프로젝트: orng/esky
 def test_copy_file(self):
     self.setContents("file1", "hello world")
     trn = FSTransaction()
     trn.copy(self.path("file1"), self.path("file2"))
     self.assertContents("file1", "hello world")
     self.assertFalse(os.path.exists(self.path("file2")))
     trn.commit()
     self.assertContents("file1", "hello world")
     self.assertContents("file2", "hello world")
예제 #2
0
파일: test_esky.py 프로젝트: orng/esky
 def test_move_dir_over_file(self):
     self.setContents("dir1/file0", "zero zero zero")
     self.setContents("dir2", "actually a file")
     trn = FSTransaction()
     trn.move(self.path("dir1"), self.path("dir2"))
     self.assertContents("dir1/file0", "zero zero zero")
     trn.commit()
     self.assertContents("dir2/file0", "zero zero zero")
     self.assertFalse(os.path.exists(self.path("dir1")))
예제 #3
0
파일: test_esky.py 프로젝트: orng/esky
 def test_move_file_with_unicode_name(self):
     self.setContents(u"file\N{SNOWMAN}", "hello world")
     trn = FSTransaction()
     trn.move(self.path(u"file\N{SNOWMAN}"), self.path("file2"))
     self.assertContents(u"file\N{SNOWMAN}", "hello world")
     self.assertFalse(os.path.exists(self.path("file2")))
     trn.commit()
     self.assertContents("file2", "hello world")
     self.assertFalse(os.path.exists(self.path(u"file\N{SNOWMAN}")))
예제 #4
0
파일: test_esky.py 프로젝트: orng/esky
 def test_copy_dir_over_file(self):
     self.setContents("dir1/file0", "zero zero zero")
     self.setContents("dir2", "actually a file")
     trn = FSTransaction()
     trn.copy(self.path("dir1"), self.path("dir2"))
     self.assertContents("dir1/file0", "zero zero zero")
     trn.commit()
     self.assertContents("dir2/file0", "zero zero zero")
     self.assertContents("dir1/file0", "zero zero zero")
예제 #5
0
 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()
예제 #6
0
파일: test_esky.py 프로젝트: orng/esky
 def test_copy_file_over_dir(self):
     self.setContents("file0", "zero zero zero")
     self.setContents("dir2/myfile", "hahahahaha!")
     trn = FSTransaction()
     trn.copy(self.path("file0"), self.path("dir2"))
     self.assertContents("file0", "zero zero zero")
     self.assertContents("dir2/myfile", "hahahahaha!")
     trn.commit()
     self.assertContents("dir2", "zero zero zero")
     self.assertContents("file0", "zero zero zero")
예제 #7
0
파일: test_esky.py 프로젝트: orng/esky
 def test_move_file_over_dir(self):
     self.setContents("file0", "zero zero zero")
     self.setContents("dir2/myfile", "hahahahaha!")
     trn = FSTransaction()
     trn.move(self.path("file0"), self.path("dir2"))
     self.assertContents("file0", "zero zero zero")
     self.assertContents("dir2/myfile", "hahahahaha!")
     trn.commit()
     self.assertContents("dir2", "zero zero zero")
     self.assertFalse(os.path.exists(self.path("file0")))
예제 #8
0
파일: test_esky.py 프로젝트: orng/esky
 def test_remove(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.commit()
     self.assertFalse(os.path.exists(self.path("dir1/file1")))
     self.assertTrue(os.path.exists(self.path("dir1")))
     trn = FSTransaction()
     trn.remove(self.path("dir1"))
     trn.commit()
     self.assertFalse(os.path.exists(self.path("dir1")))
예제 #9
0
파일: test_esky.py 프로젝트: orng/esky
 def test_move_dir(self):
     self.setContents("dir1/file1", "hello world")
     self.setContents("dir1/file2", "how are you?")
     self.setContents("dir1/subdir/file3", "fine thanks")
     trn = FSTransaction()
     trn.move(self.path("dir1"), self.path("dir2"))
     self.assertContents("dir1/file1", "hello world")
     self.assertFalse(os.path.exists(self.path("dir2")))
     trn.commit()
     self.assertContents("dir2/file1", "hello world")
     self.assertContents("dir2/file2", "how are you?")
     self.assertContents("dir2/subdir/file3", "fine thanks")
     self.assertFalse(os.path.exists(self.path("dir1")))
예제 #10
0
파일: test_esky.py 프로젝트: orng/esky
 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()
예제 #11
0
파일: test_esky.py 프로젝트: orng/esky
 def test_copy_dir_exists(self):
     self.setContents("dir1/file0", "zero zero zero")
     self.setContents("dir1/file1", "hello world")
     self.setContents("dir1/file2", "how are you?")
     self.setContents("dir1/subdir/file3", "fine thanks")
     self.setContents("dir2/file1", "different contents")
     self.setContents("dir2/file3", "a different file")
     self.setContents("dir1/subdir/file3", "fine thanks")
     trn = FSTransaction()
     trn.copy(self.path("dir1"), self.path("dir2"))
     self.assertContents("dir1/file1", "hello world")
     trn.commit()
     self.assertContents("dir2/file0", "zero zero zero")
     self.assertContents("dir2/file1", "hello world")
     self.assertContents("dir2/file2", "how are you?")
     self.assertFalse(os.path.exists(self.path("dir2/file3")))
     self.assertContents("dir2/subdir/file3", "fine thanks")
     self.assertContents("dir1/file0", "zero zero zero")
     self.assertContents("dir1/file1", "hello world")
     self.assertContents("dir1/file2", "how are you?")
     self.assertContents("dir1/subdir/file3", "fine thanks")
예제 #12
0
 def test_copy_file(self):
     self.setContents("file1", "hello world")
     trn = FSTransaction()
     trn.copy(self.path("file1"), self.path("file2"))
     self.assertContents("file1", "hello world")
     self.assertFalse(os.path.exists(self.path("file2")))
     trn.commit()
     self.assertContents("file1", "hello world")
     self.assertContents("file2", "hello world")
예제 #13
0
 def test_move_file_with_unicode_name(self):
     self.setContents(u"file\N{SNOWMAN}", "hello world")
     trn = FSTransaction()
     trn.move(self.path(u"file\N{SNOWMAN}"), self.path("file2"))
     self.assertContents(u"file\N{SNOWMAN}", "hello world")
     self.assertFalse(os.path.exists(self.path("file2")))
     trn.commit()
     self.assertContents("file2", "hello world")
     self.assertFalse(os.path.exists(self.path(u"file\N{SNOWMAN}")))
예제 #14
0
 def test_copy_dir_over_file(self):
     self.setContents("dir1/file0", "zero zero zero")
     self.setContents("dir2", "actually a file")
     trn = FSTransaction()
     trn.copy(self.path("dir1"), self.path("dir2"))
     self.assertContents("dir1/file0", "zero zero zero")
     trn.commit()
     self.assertContents("dir2/file0", "zero zero zero")
     self.assertContents("dir1/file0", "zero zero zero")
예제 #15
0
 def test_move_dir_over_file(self):
     self.setContents("dir1/file0", "zero zero zero")
     self.setContents("dir2", "actually a file")
     trn = FSTransaction()
     trn.move(self.path("dir1"), self.path("dir2"))
     self.assertContents("dir1/file0", "zero zero zero")
     trn.commit()
     self.assertContents("dir2/file0", "zero zero zero")
     self.assertFalse(os.path.exists(self.path("dir1")))
예제 #16
0
 def test_copy_file_over_dir(self):
     self.setContents("file0", "zero zero zero")
     self.setContents("dir2/myfile", "hahahahaha!")
     trn = FSTransaction()
     trn.copy(self.path("file0"), self.path("dir2"))
     self.assertContents("file0", "zero zero zero")
     self.assertContents("dir2/myfile", "hahahahaha!")
     trn.commit()
     self.assertContents("dir2", "zero zero zero")
     self.assertContents("file0", "zero zero zero")
예제 #17
0
 def test_move_file_over_dir(self):
     self.setContents("file0", "zero zero zero")
     self.setContents("dir2/myfile", "hahahahaha!")
     trn = FSTransaction()
     trn.move(self.path("file0"), self.path("dir2"))
     self.assertContents("file0", "zero zero zero")
     self.assertContents("dir2/myfile", "hahahahaha!")
     trn.commit()
     self.assertContents("dir2", "zero zero zero")
     self.assertFalse(os.path.exists(self.path("file0")))
예제 #18
0
 def test_move_dir(self):
     self.setContents("dir1/file1", "hello world")
     self.setContents("dir1/file2", "how are you?")
     self.setContents("dir1/subdir/file3", "fine thanks")
     trn = FSTransaction()
     trn.move(self.path("dir1"), self.path("dir2"))
     self.assertContents("dir1/file1", "hello world")
     self.assertFalse(os.path.exists(self.path("dir2")))
     trn.commit()
     self.assertContents("dir2/file1", "hello world")
     self.assertContents("dir2/file2", "how are you?")
     self.assertContents("dir2/subdir/file3", "fine thanks")
     self.assertFalse(os.path.exists(self.path("dir1")))
예제 #19
0
 def test_copy_dir_exists(self):
     self.setContents("dir1/file0", "zero zero zero")
     self.setContents("dir1/file1", "hello world")
     self.setContents("dir1/file2", "how are you?")
     self.setContents("dir1/subdir/file3", "fine thanks")
     self.setContents("dir2/file1", "different contents")
     self.setContents("dir2/file3", "a different file")
     self.setContents("dir1/subdir/file3", "fine thanks")
     trn = FSTransaction()
     trn.copy(self.path("dir1"), self.path("dir2"))
     self.assertContents("dir1/file1", "hello world")
     trn.commit()
     self.assertContents("dir2/file0", "zero zero zero")
     self.assertContents("dir2/file1", "hello world")
     self.assertContents("dir2/file2", "how are you?")
     self.assertFalse(os.path.exists(self.path("dir2/file3")))
     self.assertContents("dir2/subdir/file3", "fine thanks")
     self.assertContents("dir1/file0", "zero zero zero")
     self.assertContents("dir1/file1", "hello world")
     self.assertContents("dir1/file2", "how are you?")
     self.assertContents("dir1/subdir/file3", "fine thanks")
예제 #20
0
 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")))