本文整理汇总了Python中filebrowser.base.FileObject.version_name方法的典型用法代码示例。如果您正苦于以下问题:Python FileObject.version_name方法的具体用法?Python FileObject.version_name怎么用?Python FileObject.version_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类filebrowser.base.FileObject
的用法示例。
在下文中一共展示了FileObject.version_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileObjectAttributeTests
# 需要导入模块: from filebrowser.base import FileObject [as 别名]
# 或者: from filebrowser.base.FileObject import version_name [as 别名]
#.........这里部分代码省略.........
self.assertEqual(self.f_folder.is_folder, True)
self.assertEqual(self.f_folder.is_empty, False)
def test_version_attributes_1(self):
"""
FileObject version attributes/methods
without versions_basedir
# is_version
# original
# versions_basedir
# versions
# admin_versions
# version_name(suffix)
# version_path(suffix)
# version_generate(suffix)
"""
# 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']
# expected test results
version_list = ['fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg', 'fb_test_directory/fb_tmp_dir/fb_tmp_dir_sub/testimage_admin_thumbnail.jpg']
admin_version_list = ['fb_test_directory/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, "fb_test_directory/")
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"), "fb_test_directory/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, "fb_test_directory/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_version_attributes_2(self):
"""
FileObject version attributes/methods
with versions_basedir
# is_version
# original
# versions_basedir
# versions
# admin_versions
# version_name(suffix)
# version_generate(suffix)
"""
# new settings
filebrowser.base.VERSIONS_BASEDIR = "fb_test_directory/_versions"
filebrowser.base.VERSIONS = {
'admin_thumbnail': {'verbose_name': 'Admin Thumbnail', 'width': 60, 'height': 60, 'opts': 'crop'},
'large': {'verbose_name': 'Large', 'width': 600, 'height': '', 'opts': ''},