def test_aresize_no_crop_opposite_orientation_portrait(self): """ Ensure aresize_no_crop action when the source and target are the opposite orientation, and the source is portrait, that it scales according to height and mattes sides. """ renderer = LazyThumbRenderer() mock_img = MockImg(width=1000, height=2000) mock_Image = Mock() # aresize_no_crop 1000x2000 => 600x500 should thumbnail to 250x500 and # then paste into the center of a new image, leaving matte background # content on the sides. with patch('lazythumbs.views.Image', mock_Image): img = renderer.aresize_no_crop(width=600, height=500, img=mock_img) self.assertEqual(mock_img.called, ['resize']) self.assertEqual(img, mock_Image.new.return_value) self.assertEqual(mock_Image.new.call_args[1]['size'], (600, 500)) img.paste.assert_called_once_with(mock_img, (175, 0))
def test_aresize_no_crop_opposite_orientation_landscape(self): """ Ensure aresize_no_crop action when the source and target are the opposite orientation, and the source is landscape, that it scales according to width and mattes the top and bottom. """ renderer = LazyThumbRenderer() mock_img = MockImg(width=2000, height=1000) mock_Image = Mock() # aresize_no_crop 2000x1000 => 500x600 should thumbnail to 500x250 and # then paste into the center of a new image, leaving matte background # content on the top and bottom. with patch('lazythumbs.views.Image', mock_Image): img = renderer.aresize_no_crop(width=500, height=600, img=mock_img) self.assertEqual(mock_img.called, ['resize']) self.assertEqual(img, mock_Image.new.return_value) self.assertEqual(mock_Image.new.call_args[1]['size'], (500, 600)) img.paste.assert_called_once_with(mock_img, (0, 175))