Exemplo n.º 1
0
 def test__transform(self):
     item_name = u'image_Item'
     item = Binary.create(item_name)
     contenttype = u'image/jpeg'
     meta = {CONTENTTYPE: contenttype}
     item._save(meta)
     item = Binary.create(item_name)
     try:
         from PIL import Image as PILImage
         with pytest.raises(ValueError):
             result = TransformableBitmapImage._transform(item, 'text/plain')
     except ImportError:
         result = TransformableBitmapImage._transform(item, contenttype)
         assert result == (u'image/jpeg', '')
Exemplo n.º 2
0
 def test__render_data_diff_text(self):
     item_name = u'image_Item'
     item = Binary.create(item_name)
     contenttype = u'image/jpeg'
     meta = {CONTENTTYPE: contenttype}
     item._save(meta)
     item1 = Binary.create(item_name)
     data = 'test_data'
     comment = u'next revision'
     item1._save(meta, data, comment=comment)
     item2 = Binary.create(item_name)
     try:
         from PIL import Image as PILImage
         result = TransformableBitmapImage._render_data_diff_text(item1, item1.rev, item2.rev)
         expected = u'The items have different data.'
         assert result == expected
     except ImportError:
         pass
Exemplo n.º 3
0
 def test__render_data_diff(self):
     item_name = u'image_Item'
     item = Binary.create(item_name)
     contenttype = u'image/jpeg'
     meta = {CONTENTTYPE: contenttype}
     item._save(meta)
     item1 = Binary.create(item_name)
     try:
         from PIL import Image as PILImage
         result = Markup(TransformableBitmapImage._render_data_diff(item1, item.rev, item1.rev))
         # On Werkzeug 0.8.2+, urls with '+' are automatically encoded to '%2B'
         # The assert statement works with both older and newer versions of Werkzeug
         # Probably not an intentional change on the werkzeug side, see issue:
         # https://github.com/mitsuhiko/werkzeug/issues/146
         assert str(result).startswith('<img src="/+diffraw/image_Item?rev') or \
                 str(result).startswith('<img src="/%2Bdiffraw/image_Item?rev')
     except ImportError:
         # no PIL
         pass