def test_touch(self): instance=Path("sandbox/test-file") instance.remove() self.assertFalse(instance.exists()) instance.touch() self.assertTrue(instance.exists()) self.assertFalse(instance.isdir()) instance.remove() # clean up
def test_check_when_no_dir(self): # prepare import subprocess topdir = Path("sandbox").join("trash-dir") topdir.touch() assert subprocess.call(["chmod", "+t", topdir.path]) == 0 volume = Volume(Path("/mnt/disk"), True) instance = Method1VolumeTrashDirectory(topdir.join("123"), volume) instance.check()
def test_trash(self) : #instance instance=VolumeTrashDirectory( Path("sandbox/trash-directory"), Path("sandbox").volume) # test file_to_trash=Path("sandbox/dummy.txt") file_to_trash.touch() result = instance.trash(file_to_trash) self.assertTrue(isinstance(result,TrashedFile)) self.assertEquals(file_to_trash.absolute(), result.path) self.assertTrue(result.deletion_date is not None)
def test_has_sticky_bit_returns_false(self): Path("sandbox").mkdirs() non_sticky=Path("sandbox").join("non-sticky") non_sticky.touch() assert subprocess.call(["chmod", "-t", "sandbox/non-sticky"]) == 0 assert not non_sticky.has_sticky_bit()
def test_has_sticky_bit_returns_true(self): Path("sandbox").mkdirs() sticky=Path("sandbox").join("sticky") sticky.touch() assert subprocess.call(["chmod", "+t", "sandbox/sticky"]) == 0 assert sticky.has_sticky_bit()