Create function process() that does the main work of main().
[toast/gimp_passport.git] / test_gimp_passport.py
index 31a05b8..72362b9 100644 (file)
@@ -2,7 +2,7 @@ import os
 import unittest
 from PIL import Image, ImageDraw
 from gimp_passport import mm_to_pixel, num_tiles, tile_edge, line, cut_lines, cut_lines_xy,  make_passport, halo, tile, \
-    downsample_large, main
+    downsample_large, process, main
 
 
 class TestMakePassport(unittest.TestCase):
@@ -83,6 +83,15 @@ class TestMakePassport(unittest.TestCase):
         self.assertEqual(int(round(source.height / 2)), dest.height)
         self.assertEqual((45, 45), dest.info['dpi'])
 
+    def test_process(self):
+        source = Image.new('RGB', (3000, 2000), 'white')
+        img = process(150., 100., 4., 35., 45., 1., None, (1108, 280, 2180, 1620), source)
+        dpi = img.info['dpi']
+        self.assertEqual(*dpi)
+        dpi = dpi[0]
+        self.assertEqual(mm_to_pixel(100., dpi), img.height)
+        self.assertEqual(mm_to_pixel(150., dpi), img.width)
+
     def test_main(self):
         source = 'test_image.jpg'
         dest = 'test_image_result.jpg'