Ejemplo n.º 1
0
 def test__transform(self):
     item_name = 'image_Item'
     item = Item.create(item_name)
     contenttype = 'image/jpeg'
     meta = {CONTENTTYPE: contenttype}
     item._save(meta)
     item = Item.create(item_name)
     try:
         from PIL import Image as PILImage
         with pytest.raises(ValueError):
             result = TransformableBitmapImage._transform(item.content, 'text/plain')
     except ImportError:
         result = TransformableBitmapImage._transform(item.content, contenttype)
         assert result == ('image/jpeg', b'')
Ejemplo n.º 2
0
 def test__render_data_diff_text(self):
     item_name = 'image_Item'
     item = Item.create(item_name)
     contenttype = 'image/jpeg'
     meta = {CONTENTTYPE: contenttype}
     item._save(meta)
     item1 = Item.create(item_name)
     data = 'test_data'
     comment = 'next revision'
     item1._save(meta, data, comment=comment)
     item2 = Item.create(item_name)
     try:
         from PIL import Image as PILImage
         result = TransformableBitmapImage._render_data_diff_text(item1.content, item1.rev, item2.rev)
         expected = 'The items have different data.'
         assert result == expected
     except ImportError:
         pass
Ejemplo n.º 3
0
 def test__render_data_diff(self):
     item_name = 'image_Item'
     item = Item.create(item_name)
     contenttype = 'image/jpeg'
     meta = {CONTENTTYPE: contenttype}
     item._save(meta)
     item1 = Item.create(item_name)
     try:
         from PIL import Image as PILImage
         result = Markup(TransformableBitmapImage._render_data_diff(item1.content, 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