示例#1
0
 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)
示例#2
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)
示例#3
0
    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)