models_test.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:micromasters 作者: mitodl 项目源码 文件源码
def test_resized_images_updated(self):
        """
        thumbnails should be updated if image is already present and updated when update_image=True
        """
        assert self.profile.image
        assert self.profile.image_small
        assert self.profile.image_medium

        # create a dummy image file in memory for upload
        image_file = BytesIO()
        image = Image.new('RGBA', size=(50, 50), color=(256, 0, 0))
        image.save(image_file, 'png')
        image_file.seek(0)

        self.profile.image = UploadedFile(image_file, "filename.png", "image/png", len(image_file.getvalue()))
        self.profile.save(update_image=True)
        image_file_bytes = image_file.read()
        assert self.profile.image_small.file.read() != image_file_bytes
        assert self.profile.image_medium.file.read() != image_file_bytes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号