diff --git a/colab/super_archives/tests/test_utils_blocks.py b/colab/super_archives/tests/test_utils_blocks.py
new file mode 100644
index 0000000..56163f5
--- /dev/null
+++ b/colab/super_archives/tests/test_utils_blocks.py
@@ -0,0 +1,28 @@
+from django.test import TestCase
+
+from ..utils.blocks import EmailBlock, EmailBlockParser
+
+
+class TestEmailBlock(TestCase):
+
+ def setUp(self):
+ self.email_block = EmailBlock()
+
+ def test_html2text_without_br_tag(self):
+ html = 'Hello, world!'
+ text = self.email_block._html2text(html)
+
+ self.assertEquals(text, 'Hello, world!')
+
+ def test_html2text_with_br_tag(self):
+ html = 'Hello, world!
Test with br tag
!' + text = self.email_block._html2text(html) + + self.assertEquals(text, 'Hello, world!\nTest with br tag!') + + def test_mark_links(self): + html = 'http://test.org/' + text = self.email_block._mark_links(html) + + self.assertEquals(text, 'http://test.org/') diff --git a/colab/super_archives/utils/blocks.py b/colab/super_archives/utils/blocks.py index a3e868d..868488c 100644 --- a/colab/super_archives/utils/blocks.py +++ b/colab/super_archives/utils/blocks.py @@ -25,7 +25,7 @@ class EmailBlock(list): def _html2text(self, text): if RE_WRAPPED_BY_HTML.match(text.strip()): - return html2text(text) + return html2text(text).strip() text, n = RE_BR_TO_LINEBREAK.subn('\n', text) text = strip_tags(text) -- libgit2 0.21.2