mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Added tests for format filter
This commit is contained in:
parent
6c57b5b280
commit
af9d4ae5a3
@ -447,3 +447,43 @@ def register_image_operations():
|
||||
('operation1', Mock(return_value=TestFilter.operation_instance)),
|
||||
('operation2', Mock(return_value=TestFilter.operation_instance))
|
||||
]
|
||||
|
||||
|
||||
class TestFormatFilter(TestCase):
|
||||
def test_jpeg(self):
|
||||
fil = Filter(spec='width-400|format-jpeg')
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
file=get_test_image_file(),
|
||||
)
|
||||
out = fil.run(image, BytesIO())
|
||||
|
||||
self.assertEqual(out.format_name, 'jpeg')
|
||||
|
||||
def test_png(self):
|
||||
fil = Filter(spec='width-400|format-png')
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
file=get_test_image_file(),
|
||||
)
|
||||
out = fil.run(image, BytesIO())
|
||||
|
||||
self.assertEqual(out.format_name, 'png')
|
||||
|
||||
def test_gif(self):
|
||||
fil = Filter(spec='width-400|format-gif')
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
file=get_test_image_file(),
|
||||
)
|
||||
out = fil.run(image, BytesIO())
|
||||
|
||||
self.assertEqual(out.format_name, 'gif')
|
||||
|
||||
def test_invalid(self):
|
||||
fil = Filter(spec='width-400|format-foo')
|
||||
image = Image.objects.create(
|
||||
title="Test image",
|
||||
file=get_test_image_file(),
|
||||
)
|
||||
self.assertRaises(InvalidFilterSpecError, fil.run, image, BytesIO())
|
||||
|
Loading…
Reference in New Issue
Block a user