本文整理汇总了Python中filebrowser.base.FileObject.delete_admin_versions方法的典型用法代码示例。如果您正苦于以下问题:Python FileObject.delete_admin_versions方法的具体用法?Python FileObject.delete_admin_versions怎么用?Python FileObject.delete_admin_versions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类filebrowser.base.FileObject
的用法示例。
在下文中一共展示了FileObject.delete_admin_versions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileObjectAttributeTests
# 需要导入模块: from filebrowser.base import FileObject [as 别名]
# 或者: from filebrowser.base.FileObject import delete_admin_versions [as 别名]
#.........这里部分代码省略.........
self.assertEqual(f_version.exists, True)
self.assertEqual(f_version.is_version, True)
self.assertEqual(f_version.original_filename, "testimage.jpg")
self.assertEqual(f_version.original.path, self.f_image.path)
# FIXME: versions should not have versions or admin_versions
def test_version_attributes_3(self):
"""
FileObject version attributes/methods
with alternative versions_basedir
# is_version
# original
# versions_basedir
# versions
# admin_versions
# version_name(suffix)
# version_generate(suffix)
"""
# new settings
filebrowser.base.VERSIONS_BASEDIR = "_versionstestdirectory"
filebrowser.base.VERSIONS = {
'admin_thumbnail': {'verbose_name': 'Admin Thumbnail', 'width': 60, 'height': 60, 'opts': 'crop'},
'large': {'verbose_name': 'Large', 'width': 600, 'height': '', 'opts': ''},
}
filebrowser.base.ADMIN_VERSIONS = ['large']
# expected test results
version_list = ['_versionstestdirectory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg', '_versionstestdirectory/fb_tmp_dir/fb_tmp_dir_sub/testimage_admin_thumbnail.jpg']
admin_version_list = ['_versionstestdirectory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg']
self.assertEqual(self.f_image.is_version, False)
self.assertEqual(self.f_image.original.path, self.f_image.path)
self.assertEqual(self.f_image.versions_basedir, "_versionstestdirectory")
self.assertEqual(self.f_image.versions(), version_list)
self.assertEqual(self.f_image.admin_versions(), admin_version_list)
self.assertEqual(self.f_image.version_name("large"), "testimage_large.jpg")
self.assertEqual(self.f_image.version_path("large"), "_versionstestdirectory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg")
# version does not exist yet
f_version = FileObject(os.path.join(self.directory, self.tmpdir_name, "testimage_large.jpg"), site=site)
self.assertEqual(f_version.exists, False)
# generate version
f_version = self.f_image.version_generate("large")
self.assertEqual(f_version.path, "_versionstestdirectory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg")
self.assertEqual(f_version.exists, True)
self.assertEqual(f_version.is_version, True)
self.assertEqual(f_version.original_filename, "testimage.jpg")
self.assertEqual(f_version.original.path, self.f_image.path)
# FIXME: versions should not have versions or admin_versions
def test_delete(self):
"""
FileObject delete methods
# delete
# delete_versions
# delete_admin_versions
"""
# new settings
filebrowser.base.VERSIONS_BASEDIR = ""
filebrowser.base.VERSIONS = {
'admin_thumbnail': {'verbose_name': 'Admin Thumbnail', 'width': 60, 'height': 60, 'opts': 'crop'},
'large': {'verbose_name': 'Large', 'width': 600, 'height': '', 'opts': ''},
}
filebrowser.base.ADMIN_VERSIONS = ['large']
# version does not exist yet
f_version = FileObject(os.path.join(self.directory, self.tmpdir_name, "testimage_large.jpg"), site=site)
self.assertEqual(f_version.exists, False)
# generate version
f_version = self.f_image.version_generate("large")
f_version_thumb = self.f_image.version_generate("admin_thumbnail")
self.assertEqual(f_version.exists, True)
self.assertEqual(f_version_thumb.exists, True)
self.assertEqual(f_version.path, "fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg")
self.assertEqual(f_version_thumb.path, "fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_admin_thumbnail.jpg")
# delete admin versions (large)
self.f_image.delete_admin_versions()
self.assertEqual(site.storage.exists(f_version.path), False)
# delete versions (admin_thumbnail)
self.f_image.delete_versions()
self.assertEqual(site.storage.exists(f_version_thumb.path), False)
def tearDown(self):
"""
Restore original values/functions
"""
filebrowser.base.os.path = self.original_path
site.directory = self.original_directory
filebrowser.base.VERSIONS_BASEDIR = self.original_versions_basedir
filebrowser.base.VERSIONS = self.original_versions
filebrowser.base.ADMIN_VERSIONS = self.original_admin_versions
# remove temporary directory and test folder
shutil.rmtree(self.directory_path)
shutil.rmtree(self.versions_path)