コード例 #1
0
    def setUp(self):
        self.trashdirectory_base_dir = os.path.realpath(
            "./sandbox/testTrashDirectory")
        require_empty_dir(self.trashdirectory_base_dir)

        self.instance = TrashDirectoryForPut(self.trashdirectory_base_dir, "/",
                                             None, RealFs())
コード例 #2
0
    def test_for_relative_paths(self):
        self.dir = TrashDirectoryForPut('/volume/.Trash', '/volume', Mock())
        self.dir.path_maker = TopDirRelativePaths('/volume')

        self.assert_path_for_trashinfo_is('/file', '/file')
        self.assert_path_for_trashinfo_is('/file', '/dir/../file')
        self.assert_path_for_trashinfo_is('/outside/file', '/outside/file')
        self.assert_path_for_trashinfo_is('file', '/volume/file')
        self.assert_path_for_trashinfo_is('dir/file', '/volume/dir/file')
コード例 #3
0
    def test_for_relative_paths(self):
        self.dir = TrashDirectoryForPut('/volume/.Trash', '/volume')
        self.dir.store_relative_paths()

        self.assert_path_for_trashinfo_is('/file'         , '/file')
        self.assert_path_for_trashinfo_is('/file'         , '/dir/../file')
        self.assert_path_for_trashinfo_is('/outside/file' , '/outside/file')
        self.assert_path_for_trashinfo_is('file'          , '/volume/file')
        self.assert_path_for_trashinfo_is('dir/file'      , '/volume/dir/file')
コード例 #4
0
 def setUp(self):
     self.now = Mock()
     self.fs = Mock()
     self.trashdir = TrashDirectoryForPut('~/.Trash', '/', self.fs)
     self.trashdir.path_maker = TopDirRelativePaths('/')
     path_maker = Mock()
     path_maker.calc_parent_path.return_value = ''
     self.trashdir.path_maker = path_maker
     self.logger = Mock(['debug'])
コード例 #5
0
 def setUp(self):
     self.now = Mock()
     self.fs = Mock()
     self.trashdir = TrashDirectoryForPut('~/.Trash', '/', self.now,
                                          self.fs)
     self.trashdir.store_relative_paths()
     path_for_trash_info = Mock()
     path_for_trash_info.for_file.return_value = 'foo'
     self.trashdir.path_for_trash_info = path_for_trash_info
コード例 #6
0
    def test_for_absolute_paths(self):
        fs = Mock()
        self.dir = TrashDirectoryForPut('/volume/.Trash', '/volume', fs = fs)
        self.dir.store_absolute_paths()

        self.assert_path_for_trashinfo_is('/file'            , '/file')
        self.assert_path_for_trashinfo_is('/file'            , '/dir/../file')
        self.assert_path_for_trashinfo_is('/outside/file'    , '/outside/file')
        self.assert_path_for_trashinfo_is('/volume/file'     , '/volume/file')
        self.assert_path_for_trashinfo_is('/volume/dir/file' , '/volume/dir/file')
コード例 #7
0
 def setUp(self):
     self.now = lambda: datetime.datetime(1970, 1, 1)
     self.fs = Mock()
     path_maker = TopDirRelativePaths('/')
     self.info_dir = Mock(['persist_trash_info'])
     self.info_dir.persist_trash_info.return_value = 'info_file'
     self.trashdir = TrashDirectoryForPut('~/.Trash', '/', self.fs,
                                          path_maker, self.info_dir)
     path_maker = Mock()
     path_maker.calc_parent_path.return_value = ''
     self.trashdir.path_maker = path_maker
コード例 #8
0
    def test_for_absolute_paths(self):
        fs = Mock()
        path_maker = AbsolutePaths(None)
        self.dir = TrashDirectoryForPut('/volume/.Trash', '/volume', fs,
                                        path_maker, None)

        self.assert_path_for_trashinfo_is('/file'            , '/file')
        self.assert_path_for_trashinfo_is('/file'            , '/dir/../file')
        self.assert_path_for_trashinfo_is('/outside/file'    , '/outside/file')
        self.assert_path_for_trashinfo_is('/volume/file'     , '/volume/file')
        self.assert_path_for_trashinfo_is('/volume/dir/file' , '/volume/dir/file')
コード例 #9
0
    def test_what_happen_when_trashing_with_trash_dir(self):
        from trashcli.put import TrashDirectoryForPut
        fs = Mock()
        now = Mock()
        fs.mock_add_spec([
            'move', 'atomic_write', 'remove_file', 'ensure_dir',
            ], True)

        from unittest import SkipTest
        raise SkipTest("")

        trash_dir = TrashDirectoryForPut('/path', '/volume', fs)

        trash_dir.trash('garbage', now)