def test_should_list_a_trashinfo(self): make_file(self.temp_dir / 'trash-dir/info/foo.trashinfo') result = self.list_trashinfos() assert [('trashinfo', self.temp_dir / 'trash-dir/info/foo.trashinfo') ] == result
def test_non_trashinfo_should_reported_as_a_warn(self): make_file('sandbox/info/not-a-trashinfo') result = self.list_trashinfos() assert_items_equal([('non_trashinfo', 'sandbox/info/not-a-trashinfo')], result)
def test_non_trashinfo_should_reported_as_a_warn(self): make_file(self.temp_dir / 'trash-dir/info/not-a-trashinfo') result = self.list_trashinfos() six.assertCountEqual(self, [ ('non_trashinfo', self.temp_dir / 'trash-dir/info/not-a-trashinfo') ], result)
def test_restore_create_needed_directories(self): require_empty_dir('sandbox') make_file('sandbox/TrashDir/files/bar') instance = TrashedFile('sandbox/foo/bar', 'deletion_date', 'info_file', 'sandbox/TrashDir/files/bar') self.cmd.restore(instance) assert os.path.exists("sandbox/foo/bar")
def add_trashinfo(self, contents, base_name=None): if not base_name: base_name = str(self.number) self.number += 1 path = '%(info_dir)s/%(name)s.trashinfo' % { 'info_dir': self.info_path, 'name': base_name } make_parent_for(path) make_file(path, contents) self.path_of_last_file_added = path
def test_something(self): require_empty_dir('info') self.trash_directories.trash_directories_or_user.return_value = \ [("path", "/volume")] make_file('info/info_path.trashinfo', '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 '/volume/name' == trashed_file.original_location assert (datetime.datetime(2001, 1, 1, 10, 10, 10) == trashed_file.deletion_date) assert 'info/info_path.trashinfo' == trashed_file.info_file assert 'files/info_path' == trashed_file.original_file
def test_should_list_multiple_trashinfo(self): make_file('sandbox/info/foo.trashinfo') make_file('sandbox/info/bar.trashinfo') make_file('sandbox/info/baz.trashinfo') result = self.list_trashinfos() assert_items_equal([('trashinfo', 'sandbox/info/foo.trashinfo'), ('trashinfo', 'sandbox/info/baz.trashinfo'), ('trashinfo', 'sandbox/info/bar.trashinfo')], result)
def test_should_list_multiple_trashinfo(self): make_file(self.temp_dir / 'trash-dir/info/foo.trashinfo') make_file(self.temp_dir / 'trash-dir/info/bar.trashinfo') make_file(self.temp_dir / 'trash-dir/info/baz.trashinfo') result = self.list_trashinfos() six.assertCountEqual( self, [('trashinfo', self.temp_dir / 'trash-dir/info/foo.trashinfo'), ('trashinfo', self.temp_dir / 'trash-dir/info/baz.trashinfo'), ('trashinfo', self.temp_dir / 'trash-dir/info/bar.trashinfo')], result)
def add_trashed_file(self, basename, path, content): trashinfo_path = self.a_trashinfo(basename) file_path = self.file_path(basename) make_file(trashinfo_path, a_trashinfo(path)) make_file(file_path, content)
def test_should_list_a_trashinfo(self): make_file('sandbox/info/foo.trashinfo') result = self.list_trashinfos() assert_equal([('trashinfo', 'sandbox/info/foo.trashinfo')], result)