コード例 #1
0
    def test_get_body_returns_each_html_document_separately(self):
        parts = utils.get_body(self.msg_multiple_html_parts)
        self.assertEquals(2, len(parts), 'Expected two html parts.')
        first, second = parts

        self.assertIn('Hello', first)
        self.assertIn('World', second)
コード例 #2
0
    def html_safe_body(self):
        """Converts the mail body to a html safe variant by using the
        following transforms:
         - the premailer css parser.
         - The `safe_html` PortalTranforms
        """
        context = aq_inner(self.context)
        parts = utils.get_body(self.msg(), context.absolute_url())
        if not parts:
            return ''

        result = []
        for body in parts:
            body = self.rewrite_css_styles(body)
            body = utils.fix_broken_meta_tags(body)
            body = utils.unwrap_html_body(body, 'mailBody-part')
            body = self.transfrom_safe_html(body)
            result.append(body)

        return '\n'.join(result)
コード例 #3
0
 def test_get_body(self):
     self.assertEquals(0, len(utils.get_body(self.msg_empty)))
     self.assertEquals('<p>Lorem ipsum', utils.get_body(self.msg_ascii)[0][:14])