コード例 #1
0
ファイル: test.py プロジェクト: lindsay-stevens/odk_tools
 def test_prepare_base_image_no_logo(self):
     """Should return a base image with no logo."""
     settings = {'image_width': 500, 'image_height': 500,
                 'image_color': 'white', 'logo_image_path': ''}
     observed, _ = Images._prepare_base_image(settings=settings,
                                              xlsform_path="")
     expected = Images._create_blank_image(500, 500, 'white')
     self.assertEqual(list(expected.getdata()), list(observed.getdata()))
コード例 #2
0
ファイル: test.py プロジェクト: lindsay-stevens/odk_tools
 def test_all_content_types(self):
     """Should return image with label, hint and nested image."""
     settings = self.settings
     base_image, pixels_from_top = Images._prepare_base_image(
         settings=settings, xlsform_path=self.xlsform1)
     observed, _ = list(Images._prepare_question_images(
         base_image=base_image, pixels_from_top=pixels_from_top,
         settings=settings, output_path='', xlsform_path=self.xlsform1))[0]
     expected = self.ref_image_all
     diff_image = ImageChops.difference(observed, expected)
     pixel_count, diff_dict = self.quantify_image_difference(diff_image)
     self.assertTrue(diff_dict["tiny"] <= pixel_count * 0.01, diff_dict)
     self.assertTrue(diff_dict["minor"] <= pixel_count * 0.001, diff_dict)
     self.assertTrue(diff_dict["large"] == 0, diff_dict)
コード例 #3
0
ファイル: test.py プロジェクト: lindsay-stevens/odk_tools
 def test_prepare_base_image_with_logo(self):
     """Should return a base image with a logo pasted onto it."""
     logo = os.path.join(self.cwd, 'nest_images/stopc-logo.png')
     settings = {'image_width': 500, 'image_height': 500,
                 'image_color': 'white',
                 'logo_image_path': logo,
                 'logo_image_pixels_before': 10,
                 'logo_image_height': 40}
     observed, _ = Images._prepare_base_image(settings=settings,
                                              xlsform_path="")
     base_logo = os.path.join(self.cwd, 'reference_images', 'base_logo.png')
     expected = Images._open_image(image_path=base_logo)
     self.assertEqual(list(expected.getdata()), list(observed.getdata()))
     expected.close()
コード例 #4
0
ファイル: test.py プロジェクト: lindsay-stevens/odk_tools
 def test_label_only(self):
     """Should return image with label only."""
     settings = self.settings
     settings['image_content'][0]['text_hint_column'] = ''
     settings['image_content'][0]['nest_image_column'] = ''
     base_image, pixels_from_top = Images._prepare_base_image(
         settings=settings, xlsform_path=self.xlsform1)
     observed, _ = list(Images._prepare_question_images(
         base_image=base_image, pixels_from_top=pixels_from_top,
         settings=settings, output_path='', xlsform_path=self.xlsform1))[0]
     expected = self.ref_image_label
     diff_image = ImageChops.difference(observed, expected)
     pixel_count, diff_dict = self.quantify_image_difference(diff_image)
     self.assertTrue(diff_dict["tiny"] <= pixel_count * 0.01, diff_dict)
     self.assertTrue(diff_dict["minor"] <= pixel_count * 0.001, diff_dict)
     self.assertTrue(diff_dict["large"] == 0, diff_dict)