Пример #1
0
 def test_with_image(self):
     doc = self.D()
     with open(data_path('image.png')) as img:
         doc.image.save(img, 'image.jpg')
     doc.save()
     form = self.F(None, obj=doc)
     assert form.image.filename.data == 'image.jpg'
     assert form.image.bbox.data is None
Пример #2
0
 def test_with_image_and_bbox(self):
     doc = self.D()
     with open(data_path('image.png')) as img:
         doc.thumbnail.save(img, 'image.jpg', bbox=[10, 10, 100, 100])
     doc.save()
     form = self.F(None, obj=doc)
     assert form.thumbnail.filename.data == 'image.jpg'
     assert form.thumbnail.bbox.data == [10, 10, 100, 100]
Пример #3
0
    def test_post_new(self):
        tmp_filename = 'xyz/image.png'
        with open(data_path('image.png')) as img:
            tmp_filename = tmp.save(img, tmp_filename)

        form = self.F(PostData({
            'image-filename': tmp_filename,
        }))

        assert form.image.filename.data == tmp_filename
        assert form.image.bbox.data is None

        doc = self.D()
        form.populate_obj(doc)

        assert doc.image.bbox is None
        assert doc.image.filename.endswith('.png')
        assert doc.image.filename in storage
        assert tmp_filename not in tmp
Пример #4
0
    def test_post_new_with_crop(self):
        tmp_filename = 'xyz/image.png'
        with open(data_path('image.png')) as img:
            tmp_filename = tmp.save(img, tmp_filename)

        form = self.F(PostData({
            'thumbnail-filename': tmp_filename,
            'thumbnail-bbox': '10,10,100,100',
        }))

        assert form.thumbnail.filename.data == tmp_filename
        assert form.thumbnail.bbox.data == [10, 10, 100, 100]

        doc = self.D()
        form.populate_obj(doc)

        assert doc.thumbnail.bbox == [10, 10, 100, 100]
        assert doc.thumbnail.filename.endswith('.png')
        assert doc.thumbnail.filename in storage
        assert tmp_filename not in tmp