def test_get_thumbnail_of_file(self): """Test get_thumbnail_of_file.""" values = [(('Example.jpg', 100), (self.outputfile1, 'Example.jpg')), (('Example.jpg', 50), (self.outputfile2, 'Example.jpg'))] for (input_value, expected) in values: expected_value = (open(expected[0]).read(), expected[1]) output = thumbnaildownload.get_thumbnail_of_file(*input_value) self.assertEqual(output, expected_value)
def test_get_thumbnail_of_file(self): """Test get_thumbnail_of_file.""" values = [(('Example.jpg', 100), (self.outputfile1, 'Example.jpeg')), (('Example.jpg', 50), (self.outputfile2, 'Example.jpeg'))] for (input_value, expected) in values: expected_value = (open(expected[0]).read(), expected[1]) output = thumbnaildownload.get_thumbnail_of_file(*input_value) self.assertEqual(output, expected_value)
def test_get_thumbnail_of_non_existing_file(self): """Test get_thumbnail_of_file with a non-existing file.""" input_value = ('UnexistingExample.jpg', 100) with self.assertRaises(thumbnaildownload.FileDoesNotExistException): _ = thumbnaildownload.get_thumbnail_of_file(*input_value)
def test_get_thumbnail_of_file_higher_than_possible(self): """Test get_thumbnail_of_file with a size larger than available.""" input_value = ('Example.jpg', 1000) expected_value = (open(self.outputfile3).read(), 'Example.jpg') output = thumbnaildownload.get_thumbnail_of_file(*input_value) self.assertEqual(output, expected_value)
def test_get_thumbnail_of_file_error(self): """Test get_thumbnail_of_file with a bad input""" input_value = ('UnexistingExample.jpg', 100) with self.assertRaises(Exception): output = thumbnaildownload.get_thumbnail_of_file(*input_value)
def test_get_thumbnail_of_non_existing_file(self): """Test get_thumbnail_of_file with a non-existing file.""" input_value = ('UnexistingExample.jpg', 100) with self.assertRaises(thumbnaildownload.FileDoesNotExistException): _ = thumbnaildownload.get_thumbnail_of_file(*input_value)
def test_get_thumbnail_of_file_higher_than_possible(self): """Test get_thumbnail_of_file with a size larger than available.""" input_value = ('Example.jpg', 1000) expected_value = (open(self.outputfile3).read(), 'Example.jpg') output = thumbnaildownload.get_thumbnail_of_file(*input_value) self.assertEqual(output, expected_value)