def setUp(self): self.trash_directories = Mock(spec=['trash_directories_or_user']) self.trash_directory = Mock(spec=['all_info_files']) self.contents_of = Mock() self.trashed_files = TrashedFiles(self.trash_directories, self.trash_directory, self.contents_of)
class TestTrashedFilesIntegration: def setUp(self): self.trash_directories = Mock(spec=['trash_directories_or_user']) self.trash_directory = Mock(spec=['all_info_files']) self.trashed_files = TrashedFiles(self.trash_directories, self.trash_directory, contents_of) def test_something(self): require_empty_dir('info') self.trash_directories.trash_directories_or_user.return_value = \ [("path", "/volume")] open('info/info_path.trashinfo', 'w').write( 'Path=name\nDeletionDate=2001-01-01T10:10:10') self.trash_directory.all_info_files = Mock([], return_value=[ ('trashinfo', 'info/info_path.trashinfo')]) trashed_files = list(self.trashed_files.all_trashed_files([], None)) trashed_file = trashed_files[0] assert_equal('/volume/name' , trashed_file.original_location) assert_equal(datetime.datetime(2001, 1, 1, 10, 10, 10), trashed_file.deletion_date) assert_equal('info/info_path.trashinfo' , trashed_file.info_file) assert_equal('files/info_path' , trashed_file.original_file) def tearDown(self): remove_file('info/info_path.trashinfo') remove_dir_if_exists('info')
class TestTrashedFiles: def setUp(self): self.trash_directories = Mock(spec=['trash_directories_or_user']) self.trash_directory = Mock(spec=['all_info_files']) self.contents_of = Mock() self.trashed_files = TrashedFiles(self.trash_directories, self.trash_directory, self.contents_of) def test_something(self): self.trash_directories.trash_directories_or_user.return_value = \ [("path", "/volume")] self.contents_of.return_value='Path=name\nDeletionDate=2001-01-01T10:10:10' self.trash_directory.all_info_files.return_value = \ [('trashinfo', 'info/info_path.trashinfo')] trashed_files = list(self.trashed_files.all_trashed_files([], None)) trashed_file = trashed_files[0] assert_equal('/volume/name' , trashed_file.original_location) assert_equal(datetime.datetime(2001, 1, 1, 10, 10, 10), trashed_file.deletion_date) assert_equal('info/info_path.trashinfo' , trashed_file.info_file) assert_equal('files/info_path' , trashed_file.original_file) assert_equal([call.trash_directories_or_user([], None)], self.trash_directories.mock_calls)
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([])