def test_empty_image_raises(self, check_output):
     with open(self.file_path, 'a'):
         # create an empty file
         os.utime(self.file_path, None)
     with self.assertRaises(bookmark_utils.BadAlertImageError):
         bookmark_utils.attach_image(self.msg, self.url, self.file_path,
                                     self.selector)
 def test_empty_image_raises(self, run):
     run.return_value.returncode = 0
     with open(self.file_path, "a"):
         # create an empty file
         os.utime(self.file_path, None)
     with self.assertRaises(bookmark_utils.BadAlertImageError):
         bookmark_utils.attach_image(self.msg, self.url, self.file_path,
                                     self.selector)
Example #3
0
 def test_small_image_generated_with_viewport_dimensions_specified(self):
     bookmark_utils.attach_image(self.msg, self.url, self.file_path,
                                 self.selector, '100x100')
     with open(
             settings.SITE_ROOT + '/frontend/tests/fixtures/'
             'alert-email-image-small.png', 'rb') as expected:
         attachment = self.msg.attachments[0]
         self.assertEqual(attachment.get_payload().replace("\n", ""),
                          base64.b64encode(expected.read()))
 def test_small_image_generated_with_viewport_dimensions_specified(self):
     bookmark_utils.attach_image(
         self.msg, self.url, self.file_path, self.selector, '100x100')
     with open(
             settings.SITE_ROOT + '/frontend/tests/fixtures/'
             'alert-email-image-small.png', 'rb') as expected:
         attachment = self.msg.attachments[0]
         self.assertEqual(
             attachment.get_payload().replace("\n", ""),
             base64.b64encode(expected.read()))
 def test_small_image_generated_with_viewport_dimensions_specified(self):
     # Note that the expected image may differ depending on the
     # server where this is run: phantomjs interacts with the
     # display settings on a server which may vary from your own
     bookmark_utils.attach_image(self.msg, self.url, self.file_path,
                                 self.selector, '100x100')
     with open(
             settings.APPS_ROOT + '/frontend/tests/fixtures/'
             'alert-email-image-small.png', 'rb') as expected:
         attachment = self.msg.attachments[0]
         self.assertEqual(attachment.get_payload().replace("\n", ""),
                          base64.b64encode(expected.read()))
Example #6
0
 def test_image_generated(self):
     self.assertEqual(len(self.msg.attachments), 0)
     image = bookmark_utils.attach_image(self.msg, self.url, self.file_path,
                                         self.selector)
     with open(
             settings.SITE_ROOT + '/frontend/tests/fixtures/'
             'alert-email-image.png', 'rb') as expected:
         self.assertEqual(len(self.msg.attachments), 1)
         attachment = self.msg.attachments[0]
         # Check the attachment is as we expect
         self.assertEqual(attachment.get_filename(), 'image.png')
         self.assertIn(image, attachment['Content-ID'])
         # Attachments in emails are base64 *with line breaks*, so
         # we remove those.
         self.assertEqual(attachment.get_payload().replace("\n", ""),
                          base64.b64encode(expected.read()))
 def test_image_generated(self):
     self.assertEqual(len(self.msg.attachments), 0)
     image = bookmark_utils.attach_image(
         self.msg, self.url, self.file_path, self.selector)
     with open(
             settings.SITE_ROOT + '/frontend/tests/fixtures/'
             'alert-email-image.png', 'rb') as expected:
         self.assertEqual(len(self.msg.attachments), 1)
         attachment = self.msg.attachments[0]
         # Check the attachment is as we expect
         self.assertEqual(attachment.get_filename(), 'image.png')
         self.assertIn(image, attachment['Content-ID'])
         # Attachments in emails are base64 *with line breaks*, so
         # we remove those.
         self.assertEqual(
             attachment.get_payload().replace("\n", ""),
             base64.b64encode(expected.read()))
 def test_image_generated(self):
     # Note that the expected image may differ depending on the
     # server where this is run: phantomjs interacts with the
     # display settings on a server which may vary from your own
     self.assertEqual(len(self.msg.attachments), 0)
     image = bookmark_utils.attach_image(self.msg, self.url, self.file_path,
                                         self.selector)
     with open(
             settings.APPS_ROOT + '/frontend/tests/fixtures/'
             'alert-email-image.png', 'rb') as expected:
         self.assertEqual(len(self.msg.attachments), 1)
         attachment = self.msg.attachments[0]
         # Check the attachment is as we expect
         self.assertEqual(attachment.get_filename(), 'image.png')
         self.assertIn(image, attachment['Content-ID'])
         # Attachments in emails are base64 *with line breaks*, so
         # we remove those.
         self.assertEqual(attachment.get_payload().replace("\n", ""),
                          base64.b64encode(expected.read()))