def test_generates_multiple_jobs_for_multiple_images_and_widths(self):
     jobs = job_generator.generate(
         ['/foo/original-a.jpg', '/foo/original-b.jpg'], '/bar', [680, 340])
     self.assertEqual([
         resize_job.Job(
             '/foo/original-a.jpg',
             '/bar/original-a-680w.jpg',
             new_width=680,
             new_height=460),
         resize_job.Job(
             '/foo/original-a.jpg',
             '/bar/original-a-340w.jpg',
             new_width=340,
             new_height=230),
         resize_job.Job(
             '/foo/original-b.jpg',
             '/bar/original-b-680w.jpg',
             new_width=680,
             new_height=460),
         resize_job.Job(
             '/foo/original-b.jpg',
             '/bar/original-b-340w.jpg',
             new_width=340,
             new_height=230),
     ], jobs)
Example #2
0
 def test_unequal_jobs_are_not_equal(self):
     job_a = resize_job.Job('/foo/original_path.jpg',
                            '/bar/resized_path-400w.jpg',
                            new_width=400,
                            new_height=200)
     job_b = resize_job.Job('/fribby/boo.jpg',
                            '/frobby/bing-400w.jpg',
                            new_width=800,
                            new_height=600)
     self.assertNotEqual(job_a, job_b)
Example #3
0
 def test_equal_jobs_are_equal(self):
     job_a = resize_job.Job('/foo/original_path.jpg',
                            '/bar/resized_path-400w.jpg',
                            new_width=400,
                            new_height=200)
     job_b = resize_job.Job('/foo/original_path.jpg',
                            '/bar/resized_path-400w.jpg',
                            new_width=400,
                            new_height=200)
     self.assertEqual(job_a, job_b)
 def test_generates_single_job_for_single_image_and_width(self):
     jobs = job_generator.generate(['/foo/original-a.jpg'], '/bar', [340])
     self.assertEqual([
         resize_job.Job('/foo/original-a.jpg',
                        '/bar/original-a-340w.jpg',
                        new_width=340,
                        new_height=230),
     ], jobs)
    def test_resize_when_vertical_crop_is_needed(self):
        self.mock_image.size = (680, 470)

        resize.resize(resize_job.Job('large.jpg', 'small.jpg', 340, 230))

        self.mock_image.crop.assert_called_with((0, 5, 680, 465))
        self.mock_cropped_image.resize.assert_called_with((340, 230))
        self.mock_resized_image.convert.assert_called_with('RGB')
        self.mock_converted_image.save.assert_called_with('small.jpg', 'JPEG')
Example #6
0
 def test_initializes_properties(self):
     job = resize_job.Job('/foo/original_path.jpg',
                          '/bar/resized_path-400w.jpg',
                          new_width=400,
                          new_height=200)
     self.assertEqual('/foo/original_path.jpg', job.raw_path())
     self.assertEqual('/bar/resized_path-400w.jpg', job.resized_path())
     self.assertEqual(400, job.new_width())
     self.assertEqual(200, job.new_height())