Create test for make_passport.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 4 Jun 2019 21:18:23 +0000 (23:18 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 5 Jun 2019 04:11:02 +0000 (06:11 +0200)
test_gimp_passport.py

index b9b4b5f..0fd532d 100644 (file)
@@ -1,7 +1,7 @@
 import os
 import unittest
 from PIL import Image, ImageDraw
-from gimp_passport import mm_to_pixel, main, tile
+from gimp_passport import mm_to_pixel, make_passport, tile, main
 
 
 class TestMakePassport(unittest.TestCase):
@@ -11,6 +11,15 @@ class TestMakePassport(unittest.TestCase):
         self.assertEqual(200, mm_to_pixel(25.4, 200))
         self.assertEqual(600, mm_to_pixel(2*25.4, 300))
 
+    def test_make_passport(self):
+        dpi = 90
+        img = Image.new('RGBA', (mm_to_pixel(60, dpi), mm_to_pixel(80, dpi)), '#bbbbbb00')
+        img.info['dpi'] = (dpi, dpi)
+        draw = ImageDraw.ImageDraw(img)
+        draw.rectangle((50, 60, 150, 170), fill='#00bbbbff')
+        pic = make_passport(img, 0.75, 35., 45.)
+        self.assertIsInstance(pic, Image.Image)
+
     def test_tile(self):
         dpi = 90
         img = Image.new('RGB', (mm_to_pixel(35, dpi), mm_to_pixel(45, dpi)), 'lightgray')