コード例 #1
0
	def test_client_template_environment_mode_preview(self):
		tenv = MessageTemplateEnvironment()
		tenv.set_mode(MessageTemplateEnvironment.MODE_PREVIEW)
		self.assertTrue('inline_image' in tenv.globals)
		inline_image = tenv.globals['inline_image']
		img_tag_result = inline_image(testing.TEST_MESSAGE_TEMPLATE_INLINE_IMAGE)
		img_tag_test = "<img src=\"file://{0}\">".format(testing.TEST_MESSAGE_TEMPLATE_INLINE_IMAGE)
		msg = 'The preview mode failed to properly format the img HTML tag'
		self.assertEqual(img_tag_result, img_tag_test, msg=msg)
コード例 #2
0
	def test_client_template_environment_mode_send(self):
		tenv = MessageTemplateEnvironment()
		tenv.set_mode(MessageTemplateEnvironment.MODE_SEND)
		self.assertTrue('inline_image' in tenv.globals)
		inline_image = tenv.globals['inline_image']
		img_tag_result = inline_image(testing.TEST_MESSAGE_TEMPLATE_INLINE_IMAGE)
		img_tag_test = r'<img src="cid:'
		img_tag_test += self.image_cid_regex
		img_tag_test += r'">'
		msg = 'The send mode failed to properly format the img HTML tag'
		self.assertRegex(img_tag_result, img_tag_test, msg=msg)
コード例 #3
0
	def test_client_template_environment_mode_analyze(self):
		tenv = MessageTemplateEnvironment()
		self.assertTrue(hasattr(tenv, 'attachment_images'))
		self.assertIsInstance(tenv.attachment_images, dict)
		self.assertEqual(len(tenv.attachment_images), 0)

		tenv.set_mode(MessageTemplateEnvironment.MODE_ANALYZE)
		template = tenv.from_string(testing.TEST_MESSAGE_TEMPLATE)
		template.render(dict(client=dict(), url=dict()))
		msg = 'The analysis mode failed to identify the inline image'
		self.assertIn(testing.TEST_MESSAGE_TEMPLATE_INLINE_IMAGE, tenv.attachment_images, msg=msg)
		cid_value = tenv.attachment_images[testing.TEST_MESSAGE_TEMPLATE_INLINE_IMAGE]
		self.assertRegex(cid_value, self.image_cid_regex)