def test_thumbnail_noop(self): """ Test that no image operations occur if the desired w/h match image's existing w/h """ renderer = LazyThumbRenderer() mock_img = MockImg() mock_img.size = (100, 100) img = renderer.thumbnail(width=100, img=mock_img) self.assertEqual(img.size[0], 100) self.assertEqual(img.size[1], 100) self.assertEqual(len(mock_img.called), 0)
def test_thumbnail_square(self): """ Test behavior of thumbnail action when no width == height """ renderer = LazyThumbRenderer() mock_img = MockImg() mock_img.size = (100, 100) img = renderer.thumbnail(width=50, img=mock_img) self.assertEqual(img.size[0], 50) self.assertEqual(img.size[1], 50) self.assertEqual(len(mock_img.called), 1) self.assertTrue('resize' in mock_img.called)
def test_thumbnail_no_upscaling(self): """ Ensure that upscaling is forbidden in thumbnail action. """ renderer = LazyThumbRenderer() mock_img = MockImg() mock_img.size = (100, 100) img = renderer.thumbnail(width=20000, img=mock_img) self.assertEqual(img.size[0], 100) self.assertEqual(img.size[1], 100) self.assertEqual(len(mock_img.called), 0)