当前位置: 首页>>代码示例>>Python>>正文


Python Photo.delete方法代码示例

本文整理汇总了Python中photologue.models.Photo.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.delete方法的具体用法?Python Photo.delete怎么用?Python Photo.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在photologue.models.Photo的用法示例。


在下文中一共展示了Photo.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ImageResizeTest

# 需要导入模块: from photologue.models import Photo [as 别名]
# 或者: from photologue.models.Photo import delete [as 别名]
class ImageResizeTest(PhotologueBaseTest):
    def setUp(self):
        super(ImageResizeTest, self).setUp()
        self.pp = Photo(title='portrait',
            title_slug='portrait'
        )
        self.pp.image.save(os.path.basename(PORTRAIT_IMAGE_PATH),
                           ContentFile(open(PORTRAIT_IMAGE_PATH, 'rb').read()))
        self.pp.save()
        self.ps = Photo(title='square',
            title_slug='square',
        )
        self.ps.image.save(os.path.basename(SQUARE_IMAGE_PATH),
                           ContentFile(open(SQUARE_IMAGE_PATH, 'rb').read()))
        self.ps.save()

    def tearDown(self):
        super(ImageResizeTest, self).tearDown()
        self.pp.delete()
        self.ps.delete()

    def test_resize_to_fit(self):
        self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))
        self.assertEqual(self.pp.get_testPhotoSize_size(), (75, 100))
        self.assertEqual(self.ps.get_testPhotoSize_size(), (100, 100))

    def test_resize_to_fit_width(self):
        self.s.size = (100, 0)
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))
        self.assertEqual(self.pp.get_testPhotoSize_size(), (100, 133))
        self.assertEqual(self.ps.get_testPhotoSize_size(), (100, 100))

    def test_resize_to_fit_width_enlarge(self):
        self.s.size = (400, 0)
        self.s.upscale = True
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (400, 300))
        self.assertEqual(self.pp.get_testPhotoSize_size(), (400, 533))
        self.assertEqual(self.ps.get_testPhotoSize_size(), (400, 400))

    def test_resize_to_fit_height(self):
        self.s.size = (0, 100)
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (133, 100))
        self.assertEqual(self.pp.get_testPhotoSize_size(), (75, 100))
        self.assertEqual(self.ps.get_testPhotoSize_size(), (100, 100))

    def test_resize_to_fit_height_enlarge(self):
        self.s.size = (0, 400)
        self.s.upscale = True
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (533, 400))
        self.assertEqual(self.pp.get_testPhotoSize_size(), (300, 400))
        self.assertEqual(self.ps.get_testPhotoSize_size(), (400, 400))

    def test_resize_and_crop(self):
        self.s.crop = True
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), self.s.size)
        self.assertEqual(self.pp.get_testPhotoSize_size(), self.s.size)
        self.assertEqual(self.ps.get_testPhotoSize_size(), self.s.size)

    def test_resize_rounding_to_fit(self):
        self.s.size = (113, 113)
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (113, 85))
        self.assertEqual(self.pp.get_testPhotoSize_size(), (85, 113))
        self.assertEqual(self.ps.get_testPhotoSize_size(), (113, 113))

    def test_resize_rounding_cropped(self):
        self.s.size = (113, 113)
        self.s.crop = True
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), self.s.size)
        self.assertEqual(self.pp.get_testPhotoSize_size(), self.s.size)
        self.assertEqual(self.ps.get_testPhotoSize_size(), self.s.size)

    def test_resize_one_dimension_width(self):
        self.s.size = (100, 150)
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))

    def test_resize_one_dimension_height(self):
        self.s.size = (200, 75)
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))

    def test_resize_no_upscale(self):
        self.s.size = (1000, 1000)
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (200, 150))

    def test_resize_no_upscale_mixed_height(self):
        self.s.size = (400, 75)
        self.s.save()
        self.assertEqual(self.pl.get_testPhotoSize_size(), (100, 75))

    def test_resize_no_upscale_mixed_width(self):
        self.s.size = (100, 300)
#.........这里部分代码省略.........
开发者ID:42ventures,项目名称:django-photologue,代码行数:103,代码来源:resize.py


注:本文中的photologue.models.Photo.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。