def test_runs_operations_without_env_argument(self): # The "env" argument was added in Wagtail 1.5. This tests that # image operations written for 1.4 will still work run_mock = Mock() def run(willow, image): run_mock(willow, image) self.operation_instance.run = run fil = Filter(spec='operation1|operation2') image = Image.objects.create( title="Test image", file=get_test_image_file(), ) with warnings.catch_warnings(record=True) as ws: warnings.simplefilter('always') fil.run(image, BytesIO()) self.assertEqual(len(ws), 2) self.assertIs(ws[0].category, RemovedInWagtail19Warning) self.assertEqual(run_mock.call_count, 2)
def test_runs_operations(self): self.operation_instance.run = Mock() fil = Filter(spec="operation1|operation2") image = Image.objects.create(title="Test image", file=get_test_image_file()) fil.run(image, BytesIO()) self.assertEqual(self.operation_instance.run.call_count, 2)
def test_runs_operations(self): self.operation_instance.run = Mock() fil = Filter(spec='operation1|operation2') image = Image.objects.create( title="Test image", file=get_test_image_file(), ) fil.run(image, BytesIO()) self.assertEqual(self.operation_instance.run.call_count, 2)
def test_jpeg_quality_filter_overrides_setting(self): fil = Filter(spec='width-400|jpegquality-40') image = Image.objects.create( title="Test image", file=get_test_image_file_jpeg(), ) f = BytesIO() with patch('PIL.Image.Image.save') as save: fil.run(image, f) save.assert_called_with(f, 'JPEG', quality=40, optimize=True, progressive=True)
def test_runs_operations(self): run_mock = Mock() def run(willow, image, env): run_mock(willow, image, env) self.operation_instance.run = run fil = Filter(spec='operation1|operation2') image = Image.objects.create( title="Test image", file=get_test_image_file(), ) fil.run(image, BytesIO()) self.assertEqual(run_mock.call_count, 2)
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')