示例#1
0
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')
示例#2
0
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)