def test_generate_filename(self): tests = ( ((85, False), ('testing.jpg', 50, 50), 'testing_jpg_50x50_q85_ctf.jpg'), ((85, False), ('testing.png', 50, 50), 'testing_png_50x50_q85_ctf.png'), ((75, True), ('testing.jpg', 75, 75), 'testing_jpg_75x75_q75_up_ctf.jpg') ) for test in tests: proc = CropToFitProcessor(quality=test[0][0], upscale=test[0][1]) self.assertEqual(proc.generate_filename(*test[1]), test[2])
def test_generate_thumbnail(self): image = Image.new('RGB', PIC_SIZE) tests = ( (False, (400, 300), (400, 300)), (False, (400, 400), (400, 400)), (True, (1600, 1200), (1600, 1200)), ) for test in tests: proc = CropToFitProcessor(upscale=test[0]) thumb = proc.generate_thumbnail(image, *test[1]) self.assertEqual(thumb.size, test[2])