test_admin_views.py 文件源码

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

项目:Wagtail-Image-Folders 作者: anteatersa 项目源码 文件源码
def test_add_too_large_file(self):
        file_content = get_test_image_file().file.getvalue()

        response = self.post({
            'title': "Test image",
            'file': SimpleUploadedFile('test.png', file_content),
        })

        # Shouldn't redirect anywhere
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'wagtailimages/images/add.html')

        # The form should have an error
        self.assertFormError(
            response, 'form', 'file',
            "This file is too big ({file_size}). Maximum filesize {max_file_size}.".format(
                file_size=filesizeformat(len(file_content)),
                max_file_size=filesizeformat(1),
            )
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号