예제 #1
0
 def test_doesnt_alter_input_paste_image(self):
     """Resizing should be done on a copy, not the original."""
     base_image = Images._create_blank_image(500, 500, 'red')
     paste_image = Images._create_blank_image(600, 600, 'blue')
     expected = (600, 600)
     Images._paste_image(
         base_image=base_image, pixels_from_top=20,
         paste_image=paste_image, pixels_before=20, max_height=50)
     observed = paste_image.size
     self.assertEqual(expected, observed)
예제 #2
0
 def test_shrink_square_to_available(self):
     """Should resize to width."""
     pixels_from_top = 0
     base_image = Images._create_blank_image(500, 500, 'red')
     paste_image = Images._create_blank_image(600, 600, 'blue')
     pixels_before = 5
     expected = 485
     base_image, observed = Images._paste_image(
         base_image=base_image, pixels_from_top=pixels_from_top,
         paste_image=paste_image, pixels_before=pixels_before,
         max_height=None)
     self.assertEqual(expected, observed)
예제 #3
0
 def test_shrink_square_to_available_with_y_offset(self):
     """Should resize to fit available space."""
     base_image = Images._create_blank_image(500, 500, 'red')
     pixels_from_top = 50
     paste_image = Images._create_blank_image(600, 600, 'blue')
     pixels_before = 5
     expected = 490
     base_image, observed = Images._paste_image(
         base_image=base_image, pixels_from_top=pixels_from_top,
         paste_image=paste_image, pixels_before=pixels_before,
         max_height=None)
     self.assertEqual(expected, observed)
예제 #4
0
 def test_shrink_tall_to_max_height_with_y_offset(self):
     """Should resize to max_height."""
     base_image = Images._create_blank_image(500, 500, 'red')
     pixels_from_top = 100
     paste_image = Images._create_blank_image(750, 600, 'blue')
     pixels_before = 5
     max_height = 250
     expected = 355
     base_image, observed = Images._paste_image(
         base_image=base_image, pixels_from_top=pixels_from_top,
         paste_image=paste_image, pixels_before=pixels_before,
         max_height=max_height)
     self.assertEqual(expected, observed)