Ejemplo n.º 1
0
 def test_width_rendition_size(self):
     image = CFGOVImage(file=self.mock_gif, width=500, height=300)
     rendition = image.get_rendition('width-250')
     self.assertEqual(
         (rendition.width, rendition.height),
         (250, 150)
     )
Ejemplo n.º 2
0
 def test_width_rendition_img_tag(self):
     image = CFGOVImage(file=self.mock_gif, width=500, height=300)
     rendition = image.get_rendition('width-250')
     self.assertEqual(
         rendition.img_tag(),
         '<img alt="" height="150" src="https://url" width="250">'
     )
Ejemplo n.º 3
0
 def test_width_rendition_img_tag(self):
     image = CFGOVImage(file=self.mock_gif, width=500, height=300)
     rendition = image.get_rendition('width-250')
     self.assertEqual(
         rendition.img_tag(),
         '<img alt="" height="150" src="https://url" width="250">'
     )
Ejemplo n.º 4
0
 def test_max_size_rendition_img_tag(self):
     mock_image = Mock(url='https://url')
     image = CFGOVImage(file=mock_image, width=100, height=100)
     rendition = image.get_rendition('max-165x165')
     self.assertEqual(
         rendition.img_tag(),
         '<img alt="" height="100" src="https://url" width="100">')
Ejemplo n.º 5
0
 def test_image_original_rendition_img_tag(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition = image.get_rendition('original')
     self.assertEqual(
         rendition.img_tag(),
         '<img alt="" height="100" src="https://url" width="100">'
     )
Ejemplo n.º 6
0
 def test_width_rendition_size(self):
     image = CFGOVImage(file=self.mock_gif, width=500, height=300)
     rendition = image.get_rendition('width-250')
     self.assertEqual(
         (rendition.width, rendition.height),
         (250, 150)
     )
Ejemplo n.º 7
0
 def test_image_original_rendition_img_tag(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition = image.get_rendition('original')
     self.assertEqual(
         rendition.img_tag(),
         '<img alt="" height="100" src="https://url" width="100">'
     )
Ejemplo n.º 8
0
 def test_max_size_rendition_img_tag(self):
     mock_image = Mock(url='https://url')
     image = CFGOVImage(file=mock_image, width=100, height=100)
     rendition = image.get_rendition('max-165x165')
     self.assertEqual(
         rendition.img_tag(),
         '<img alt="" height="100" src="https://url" width="100">'
     )
Ejemplo n.º 9
0
 def test_image_original_filter_class(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition_filter = Filter(spec='original')
     rendition = image.get_rendition(rendition_filter)
     self.assertEqual(rendition.file, image.file)
Ejemplo n.º 10
0
 def test_twitter_card_large(self):
     """ Twitter card property should be true if meta image is large """
     image = CFGOVImage(width=1200, height=600)
     self.assertTrue(image.should_display_summary_large_image)
Ejemplo n.º 11
0
 def test_non_resize_rendition_raises_for_gif(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     with self.assertRaises(RuntimeError):
         image.get_rendition('fill-200x200')
Ejemplo n.º 12
0
 def test_image_original_rendition_size(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition = image.get_rendition('original')
     self.assertEqual(rendition.width, image.width)
     self.assertEqual(rendition.height, image.height)
Ejemplo n.º 13
0
 def test_original_rendition_makes_mock_rendition_for_gif(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition = image.get_rendition('original')
     self.assertEqual(rendition.image, image)
Ejemplo n.º 14
0
 def test_non_resize_rendition_calls_super_for_png(self):
     with patch('v1.models.images.AbstractImage.get_rendition') as p:
         image = CFGOVImage(file=self.mock_png, width=100, height=100)
         image.get_rendition('fill-200x200')
         p.assert_called_once_with('fill-200x200')
Ejemplo n.º 15
0
 def test_non_resize_rendition_calls_super_for_png(self):
     with patch('v1.models.images.AbstractImage.get_rendition') as p:
         image = CFGOVImage(file=self.mock_png, width=100, height=100)
         image.get_rendition('fill-200x200')
         p.assert_called_once_with('fill-200x200')
Ejemplo n.º 16
0
 def test_original_rendition_makes_mock_rendition_for_gif(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition = image.get_rendition('original')
     self.assertEqual(rendition.image, image)
Ejemplo n.º 17
0
 def test_max_size_rendition(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition = image.get_rendition('max-165x165')
     self.assertEqual(rendition.width, 100)
     self.assertEqual(rendition.height, 100)
Ejemplo n.º 18
0
 def test_max_size_rendition(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition = image.get_rendition('max-165x165')
     self.assertEqual(rendition.width, 100)
     self.assertEqual(rendition.height, 100)
Ejemplo n.º 19
0
 def test_non_resize_rendition_raises_for_gif(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     with self.assertRaises(RuntimeError):
         image.get_rendition('fill-200x200')
Ejemplo n.º 20
0
 def test_image_original_filter_class(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition_filter = Filter(spec='original')
     rendition = image.get_rendition(rendition_filter)
     self.assertEqual(rendition.file, image.file)
Ejemplo n.º 21
0
 def test_image_original_rendition_size(self):
     image = CFGOVImage(file=self.mock_gif, width=100, height=100)
     rendition = image.get_rendition('original')
     self.assertEqual(rendition.width, image.width)
     self.assertEqual(rendition.height, image.height)
Ejemplo n.º 22
0
 def test_twitter_card_large_bad_ratio(self):
     """ Twitter card property should be false if meta image ratio isn't ~ 50% """
     image = CFGOVImage(width=1200, height=100)
     self.assertFalse(image.should_display_summary_large_image)
Ejemplo n.º 23
0
 def test_original_rendition_calls_super_for_png(self):
     image = CFGOVImage(file=self.mock_png, width=100, height=100)
     with patch('v1.models.images.AbstractImage.get_rendition') as p:
         image.get_rendition('original')
         p.assert_called_once_with('original')
Ejemplo n.º 24
0
 def test_twitter_card_small(self):
     """ Twitter card property should be false if meta image is small """
     image = CFGOVImage(width=100, height=50)
     self.assertFalse(image.should_display_summary_large_image)
Ejemplo n.º 25
0
 def test_original_rendition_calls_super_for_png(self):
     image = CFGOVImage(file=self.mock_png, width=100, height=100)
     with patch('v1.models.images.AbstractImage.get_rendition') as p:
         image.get_rendition('original')
         p.assert_called_once_with('original')