def test_wrong_init_parameters(self): with self.assertRaises(ValueError): UpscaleFilter(**{}) with self.assertRaises(ValueError): UpscaleFilter(**{'min': 'string'}) with self.assertRaises(ValueError): UpscaleFilter(**{'min': []}) with self.assertRaises(ValueError): UpscaleFilter(**{'min': [1]}) with self.assertRaises(ValueError): UpscaleFilter(**{'min': [1, 2, 3]})
def test_big_image(self): upscale = UpscaleFilter(**{'min': [800, 600]}) image_png = copy(self.image_png) image_png = upscale.apply(image_png) self.assertTupleEqual((1000, 500), image_png.size) image_jpg = copy(self.image_jpg) image_jpg = upscale.apply(image_jpg) self.assertTupleEqual((1000, 500), image_jpg.size) image_tif = copy(self.image_tif) image_tif = upscale.apply(image_tif) self.assertTupleEqual((1000, 500), image_tif.size) image_bmp = copy(self.image_bmp) image_bmp = upscale.apply(image_bmp) self.assertTupleEqual((1000, 500), image_bmp.size) image_vertical = copy(self.image_vertical) image_vertical = upscale.apply(image_vertical) self.assertTupleEqual((500, 1000), image_vertical.size)
def test_small_image(self): upscale = UpscaleFilter(**{'min': [1920, 1080]}) image_png = copy(self.image_png) image_png = upscale.apply(image_png) self.assertTupleEqual((1920, 960), image_png.size) image_jpg = copy(self.image_jpg) image_jpg = upscale.apply(image_jpg) self.assertTupleEqual((1920, 960), image_jpg.size) image_tif = copy(self.image_tif) image_tif = upscale.apply(image_tif) self.assertTupleEqual((1920, 960), image_tif.size) image_bmp = copy(self.image_bmp) image_bmp = upscale.apply(image_bmp) self.assertTupleEqual((1920, 960), image_bmp.size) image_vertical = copy(self.image_vertical) image_vertical = upscale.apply(image_vertical) self.assertTupleEqual((540, 1080), image_vertical.size)
def test_wrong_resource_type(self): upscale = UpscaleFilter(**{'min': [800, 600]}) with self.assertRaises(ValueError): upscale.apply('string')