def __call__(self, from_dir='/', with_user_typing=''): RestoreCmd(stdout=self.out, stderr=self.err, environ=self.environ, exit=[].append, input=lambda msg: with_user_typing, curdir=lambda: from_dir).run([])
def setUp(self): self.stdout = StringIO() self.stderr = StringIO() self.cmd = RestoreCmd(stdout=self.stdout, stderr=self.stderr, environ={}, exit=self.capture_exit_status, input=lambda x: self.user_reply, version=None)
def run_restore(self, with_user_typing=''): RestoreCmd(stdout=self.out, stderr=self.err, environ={ 'XDG_DATA_HOME': self.XDG_DATA_HOME }, exit=[].append, input=lambda msg: with_user_typing, curdir=lambda: self.current_dir).run([])
def restore(): from trashcli.restore import RestoreCmd try: # Python 2 input23 = raw_input except: # Python 3 input23 = input RestoreCmd(stdout=sys.stdout, stderr=sys.stderr, environ=os.environ, exit=sys.exit, input=input23).run(sys.argv)
def setUp(self): trash_directories = make_trash_directories() trashed_files = TrashedFiles(trash_directories, None, contents_of) self.cmd = RestoreCmd(None, None, exit=None, input=None, curdir=lambda: "dir", trashed_files=trashed_files, mount_points=os_mount_points) self.cmd.handle_trashed_files = self.capture_trashed_files self.trashed_files = Mock(spec=['all_trashed_files']) self.cmd.trashed_files = self.trashed_files
def setUp(self): remove_file_if_exists('parent/path') remove_dir_if_exists('parent') trash_directories = make_trash_directories() trashed_files = TrashedFiles(trash_directories, TrashDirectory(), contents_of) self.cmd = RestoreCmd(None, None, exit=None, input=None, trashed_files=trashed_files, mount_points=os_mount_points)
def setUp(self): self.temp_dir = MyPath.make_temp_dir() trash_directories = make_trash_directories() trashed_files = TrashedFiles(trash_directories, TrashDirectory(), contents_of) self.cmd = RestoreCmd(None, None, exit=None, input=None, trashed_files=trashed_files, mount_points=os_mount_points, fs=restore.FileSystem())
def setUp(self): self.stdout = StringIO() self.stderr = StringIO() trash_directories = make_trash_directories() trashed_files = TrashedFiles(trash_directories, TrashDirectory(), contents_of) self.cmd = RestoreCmd(stdout=self.stdout, stderr=self.stderr, exit = self.capture_exit_status, input =lambda x: self.user_reply, version=None, trashed_files=trashed_files, mount_points=os_mount_points)
def run_restore(self, with_user_typing=''): environ = {'XDG_DATA_HOME': self.XDG_DATA_HOME} trash_directories = TrashDirectories(volume_of, os.getuid, environ) trash_directories2 = TrashDirectories2(volume_of, trash_directories) trashed_files = TrashedFiles(trash_directories2, TrashDirectory(), contents_of) RestoreCmd(stdout=self.out, stderr=self.err, exit=[].append, input=lambda msg: with_user_typing, curdir=lambda: self.current_dir, trashed_files=trashed_files, mount_points=os_mount_points).run([])
def test_something(self): cmd = RestoreCmd(None, None, {}, None, None) cmd.contents_of = lambda path: 'Path=name\nDeletionDate=2001-01-01T10:10:10' path_to_trashinfo = 'info/info_path.trashinfo' trash_dir = Mock([]) trash_dir.volume = '/volume' trash_dir.all_info_files = Mock([], return_value=[path_to_trashinfo]) cmd.all_trash_directories2 = lambda: [trash_dir] cmd.curdir = lambda: '/volume' trashed_files = list(cmd.all_trashed_files()) trashed_file = trashed_files[0] assert_equals('/volume/name', trashed_file.original_location) assert_equals(datetime.datetime(2001, 1, 1, 10, 10, 10), trashed_file.deletion_date) assert_equals('info/info_path.trashinfo', trashed_file.info_file) assert_equals('files/info_path', trashed_file.original_file)
def setUp(self): self.cmd = RestoreCmd(None, None, None, None, None) self.cmd.curdir = lambda: "dir" self.cmd.handle_trashed_files = self.capture_trashed_files
def setUp(self): remove_file_if_exists('parent/path') remove_dir_if_exists('parent') self.cmd = RestoreCmd(None, None, None, None, None)