Exemplo n.º 1
0
    def test_post_new(self):
        tmp_filename = 'xyz/image.png'
        with open(self.data('image.png')) as img:
            tmp_filename = tmp.save(img, tmp_filename)

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

        self.assertEqual(form.image.filename.data, tmp_filename)
        self.assertEqual(form.image.bbox.data, None)

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

        self.assertIsNone(doc.image.bbox)
        self.assertTrue(doc.image.filename.endswith('.png'))
        self.assertIn(doc.image.filename, storage)
        self.assertNotIn(tmp_filename, tmp)
Exemplo n.º 2
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
Exemplo n.º 3
0
    def test_post_new(self):
        tmp_filename = 'xyz/image.png'
        with open(self.data('image.png')) as img:
            tmp_filename = tmp.save(img, tmp_filename)

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

        self.assertEqual(form.image.filename.data, tmp_filename)
        self.assertEqual(form.image.bbox.data, None)

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

        self.assertIsNone(doc.image.bbox)
        self.assertTrue(doc.image.filename.endswith('.png'))
        self.assertIn(doc.image.filename, storage)
        self.assertNotIn(tmp_filename, tmp)
Exemplo n.º 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
Exemplo n.º 5
0
    def test_post_new_with_crop(self):
        tmp_filename = 'xyz/image.png'
        with open(self.data('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',
        }))

        self.assertEqual(form.thumbnail.filename.data, tmp_filename)
        self.assertEqual(form.thumbnail.bbox.data, [10, 10, 100, 100])

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

        self.assertEqual(doc.thumbnail.bbox, [10, 10, 100, 100])
        self.assertTrue(doc.thumbnail.filename.endswith('.png'))
        self.assertIn(doc.thumbnail.filename, storage)
        self.assertNotIn(tmp_filename, tmp)
Exemplo n.º 6
0
    def test_post_new_with_crop(self):
        tmp_filename = 'xyz/image.png'
        with open(self.data('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',
            }))

        self.assertEqual(form.thumbnail.filename.data, tmp_filename)
        self.assertEqual(form.thumbnail.bbox.data, [10, 10, 100, 100])

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

        self.assertEqual(doc.thumbnail.bbox, [10, 10, 100, 100])
        self.assertTrue(doc.thumbnail.filename.endswith('.png'))
        self.assertIn(doc.thumbnail.filename, storage)
        self.assertNotIn(tmp_filename, tmp)