Пример #1
0
 def clean_message_content_fields(self):
     """
     If :obj:`.BaseMessage.message_content_html` has content and :obj:`.BaseMessage.message_content_plain`
     has not, convert the HTML-content to plaintext and set it on the `message_content_plain`-field.
     """
     if self.message_content_html and not self.message_content_plain:
         self.message_content_plain = emailutils.convert_html_to_plaintext(self.message_content_html).strip()
Пример #2
0
 def clean_message_content_fields(self):
     """
     If :obj:`.BaseMessage.message_content_html` has content and :obj:`.BaseMessage.message_content_plain`
     has not, convert the HTML-content to plaintext and set it on the `message_content_plain`-field.
     """
     if self.message_content_html and not self.message_content_plain:
         self.message_content_plain = emailutils.convert_html_to_plaintext(
             self.message_content_html).strip()
Пример #3
0
 def test_single_paragraph(self):
     self.assertEqual(
         emailutils.convert_html_to_plaintext('<p>Hello</p>').strip(),
         'Hello')
Пример #4
0
 def test_link_with_classes(self):
     self.assertEqual(
         emailutils.convert_html_to_plaintext(
             '<a href="http://example.com" class="btn">Example</a>').strip(
             ), '[Example](http://example.com)')
Пример #5
0
 def test_italic(self):
     self.assertEqual(
         emailutils.convert_html_to_plaintext('<em>Hello</em>').strip(),
         '_Hello_')
Пример #6
0
 def test_bold(self):
     self.assertEqual(
         emailutils.convert_html_to_plaintext(
             '<strong>Hello</strong>').strip(), '**Hello**')
Пример #7
0
 def test_multiple_paragraphs(self):
     self.assertEqual(
         emailutils.convert_html_to_plaintext(
             '<p>Hello</p><p>World</p>').strip(), 'Hello\n\nWorld')