From 52d7f2c6faf3672da0e6b9079d622698f4b88371 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Wed, 27 Aug 2014 12:12:03 +0100 Subject: [PATCH] Added failing test for #573 --- wagtail/wagtailimages/tests.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/wagtail/wagtailimages/tests.py b/wagtail/wagtailimages/tests.py index dabd5e0e8d..d040a922d8 100644 --- a/wagtail/wagtailimages/tests.py +++ b/wagtail/wagtailimages/tests.py @@ -32,7 +32,7 @@ from wagtail.tests.models import EventPage, EventPageCarouselItem from wagtail.wagtailcore.models import Page -def get_test_image_file(): +def get_test_image_file(filename='test.png'): from six import BytesIO from PIL import Image from django.core.files.images import ImageFile @@ -40,7 +40,7 @@ def get_test_image_file(): f = BytesIO() image = Image.new('RGB', (640, 480), 'white') image.save(f, 'PNG') - return ImageFile(f, name='test.png') + return ImageFile(f, name=filename) Image = get_image_model() @@ -1016,3 +1016,24 @@ class TestCropToPoint(TestCase): CropBox(125, 25, 275, 175), ) + +class TestIssue573(TestCase): + """ + This tests for a bug which causes filename limit on Renditions to be reached + when the Image has a long original filename and a big focal point key + """ + def test_issue_573(self): + # Create an image with a big filename and focal point + image = Image.objects.create( + title="Test image", + file=get_test_image_file('thisisaverylongfilename-abcdefghijklmnopqrstuvwxyz-supercalifragilisticexpialidocious.png'), + focal_point_x=1000, + focal_point_y=1000, + focal_point_width=1000, + focal_point_height=1000, + ) + + # Try creating a rendition from that image + # This would crash if the bug is present + image.get_rendition('fill-800x600') +