Example #1
0
 def test09_cleanup(self):
     """Test cleanup."""
     with LogCapture('iiif.manipulator') as lc:
         m = IIIFManipulatorPIL()
         m.outtmp = None
         self.assertEqual(m.cleanup(), None)
         m.outtmp = '/this_will_not_exist_really_I_hope'
         self.assertEqual(m.cleanup(), None)
         self.assertEqual(lc.records[-1].msg,
                          'Failed to cleanup tmp output file /this_will_not_exist_really_I_hope')
Example #2
0
 def test08_do_format(self):
     """Test format selection."""
     m = IIIFManipulatorPIL()
     m.srcfile = 'testimages/test1.png'
     # default is jpeg
     m.do_first()
     self.assertEqual(m.do_format(None), None)
     img = Image.open(m.outfile)
     self.assertEqual(img.format, 'JPEG')
     m.cleanup()
     # request jpeg
     m.do_first()
     self.assertEqual(m.do_format('jpg'), None)
     img = Image.open(m.outfile)
     self.assertEqual(img.format, 'JPEG')
     m.cleanup()
     # request png
     m.do_first()
     self.assertEqual(m.do_format('png'), None)
     img = Image.open(m.outfile)
     self.assertEqual(img.format, 'PNG')
     m.cleanup()
     # request webp
     m.do_first()
     self.assertEqual(m.do_format('webp'), None)
     img = Image.open(m.outfile)
     self.assertEqual(img.format, 'WEBP')
     m.cleanup()
     # request tiff, not supported
     m.do_first()
     self.assertRaises(IIIFError, m.do_format, 'tif')
     # request jp2, not supported
     m.do_first()
     self.assertRaises(IIIFError, m.do_format, 'jp2')
     # request other, not supported
     m.do_first()
     self.assertRaises(IIIFError, m.do_format, 'other')
     # save to specific location
     m.outfile = tempfile.NamedTemporaryFile(delete=True).name
     self.assertFalse(os.path.exists(m.outfile))  # check setup
     m.do_first()
     self.assertEqual(m.do_format(None), None)
     self.assertTrue(os.path.exists(m.outfile))
Example #3
0
 def test08_do_format(self):
     """Test format selection."""
     m = IIIFManipulatorPIL()
     m.srcfile = 'testimages/test1.png'
     # default is jpeg
     m.do_first()
     self.assertEqual(m.do_format(None), None)
     img = Image.open(m.outfile)
     self.assertEqual(img.format, 'JPEG')
     m.cleanup()
     # request jpeg
     m.do_first()
     self.assertEqual(m.do_format('jpg'), None)
     img = Image.open(m.outfile)
     self.assertEqual(img.format, 'JPEG')
     m.cleanup()
     # request png
     m.do_first()
     self.assertEqual(m.do_format('png'), None)
     img = Image.open(m.outfile)
     self.assertEqual(img.format, 'PNG')
     m.cleanup()
     # request webp
     m.do_first()
     self.assertEqual(m.do_format('webp'), None)
     img = Image.open(m.outfile)
     self.assertEqual(img.format, 'WEBP')
     m.cleanup()
     # request tiff, not supported
     m.do_first()
     self.assertRaises(IIIFError, m.do_format, 'tif')
     # request jp2, not supported
     m.do_first()
     self.assertRaises(IIIFError, m.do_format, 'jp2')
     # request other, not supported
     m.do_first()
     self.assertRaises(IIIFError, m.do_format, 'other')
     # save to specific location
     m.outfile = tempfile.NamedTemporaryFile(delete=True).name
     self.assertFalse(os.path.exists(m.outfile))  # check setup
     m.do_first()
     self.assertEqual(m.do_format(None), None)
     self.assertTrue(os.path.exists(m.outfile))
Example #4
0
 def test_cleanup(self):
     m = IIIFManipulatorPIL()
     m.outtmp = None
     self.assertEqual( m.cleanup(), None )
     m.outtmp = '/this_will_not_exits_really_I_hope'
     self.assertEqual( m.cleanup(), None )