Exemplo n.º 1
0
def main(argv=sys.argv[1:]):
    from optparse import OptionParser
    from trashcli.trash import volume_of

    (options, args) = OptionParser().parse_args(argv)

    for arg in args :
        print '%s is in volume %s ' % (arg, volume_of(arg))
Exemplo n.º 2
0
 def test_check_pass(self):
     # prepare
     import subprocess
     topdir = "sandbox/trash-dir"
     mkdirs(topdir)
     assert subprocess.call(["chmod", "+t", topdir]) == 0
     volume = volume_of("/mnt/disk")
     instance = Method1VolumeTrashDirectory(os.path.join(topdir,"123"), volume)
     
     instance.check() # should pass
Exemplo n.º 3
0
    def test_path_for_trashinfo (self) : 
        instance = HomeTrashDirectory("/home/user/.local/share/Trash")
        instance.volume = volume_of("/")

        # path for HomeTrashDirectory are always absolute
        fileToBeTrashed="/home/user/test.txt"
        result=instance._path_for_trashinfo(fileToBeTrashed)
        self.assertEquals("/home/user/test.txt",result)
            
        #  ... even if the file is under /home/user/.local/share
        fileToBeTrashed="/home/user/.local/share/test.txt"
        result=instance._path_for_trashinfo(fileToBeTrashed)
        self.assertEquals(os.path.abspath("/home/user/.local/share/test.txt"),result)
Exemplo n.º 4
0
    def test_trash(self) :
        #instance
        instance=VolumeTrashDirectory(
                        "sandbox/trash-directory", 
                        volume_of("sandbox"))

        # test
        file_to_trash="sandbox/dummy.txt"
        touch(file_to_trash)
        result = instance.trash(file_to_trash)
        self.assertTrue(isinstance(result,TrashedFile))
        self.assertEquals(abspath(file_to_trash), result.path)
        self.assertTrue(result.deletion_date is not None)
Exemplo n.º 5
0
 def test_check_when_is_symlink(self):
     # prepare
     import subprocess
     topdir = "sandbox/trash-dir"
     mkdirs(topdir)
     assert subprocess.call(["chmod", "+t", topdir]) == 0
     
     topdir_link = "sandbox/trash-dir-link"
     os.symlink('./trash-dir', topdir_link)
     volume = volume_of("/mnt/disk")
     instance = Method1VolumeTrashDirectory(os.path.join(topdir_link,"123"), volume)
     
     instance.check()
Exemplo n.º 6
0
 def test_calc_original_location_when_absolute(self) :
     instance = TrashDirectory( "/mnt/disk/.Trash-123", volume_of("/mnt/disk"))
     
     assert_equals("/foo", instance._calc_original_location("/foo"))
Exemplo n.º 7
0
 def test_get_files_dir(self):
     instance=TrashDirectory( "/mnt/disk/.Trash-123", volume_of("/mnt/disk"))
     self.assertEquals("/mnt/disk/.Trash-123/files", instance.files_dir)
Exemplo n.º 8
0
 def test_get_info_dir(self):
     instance=TrashDirectory( "/mnt/disk/.Trash-123", volume_of("/mnt/disk"))
     self.assertEquals("/mnt/disk/.Trash-123/info", instance.info_dir)
Exemplo n.º 9
0
 def test_init(self) :
     path = "/mnt/disk/.Trash/123"
     volume = volume_of("/mnt/disk")
     instance = VolumeTrashDirectory(path, volume)
     self.assertEquals(path, instance.path)
     self.assertEquals(volume, instance.volume)