def test_auto_should_optimize_jpeg_to_jpeg(self): optimizer = AutoOptimizer(self.get_context()) temp = tempfile.NamedTemporaryFile() optimizer.optimize(None, fixtures_folder + '/img/bend.jpg', temp.name) temp_buffer = open(temp.name).read() self.assertTrue(BaseEngine.get_mimetype(temp_buffer) == 'image/jpeg', "MIME type should be image/jpeg")
def test_auto_should_optimize_jpg(self): optimizer = AutoOptimizer(self.get_context()) temp = tempfile.NamedTemporaryFile() optimizer.optimize(None, fixtures_folder + '/img/bend.jpg', temp.name) self.assertLessEqual(os.path.getsize(temp.name), os.path.getsize(fixtures_folder + '/img/bend.jpg'), "Auto could not lower filesize for img/bend.jpg")
def test_auto_should_run_for_png(self): optimizer = AutoOptimizer(self.get_context()) self.assertTrue(optimizer.should_run('png', None))
def test_auto_should_not_run_for_gif(self): optimizer = AutoOptimizer(self.get_context()) self.assertFalse(optimizer.should_run('gif', None))