Commit ee8381d8a0598b5fa054ca0e2f4cd93e227196fa
1 parent
a8f823fe
Exists in
master
and in
4 other branches
super_archives: test EmailBlock
Fix _html2text method, added a strip in return Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com> Signed-off-by: Tomaz Martins <tomaz.r.martins@gmail.com>
Showing
2 changed files
with
29 additions
and
1 deletions
Show diff stats
... | ... | @@ -0,0 +1,28 @@ |
1 | +from django.test import TestCase | |
2 | + | |
3 | +from ..utils.blocks import EmailBlock, EmailBlockParser | |
4 | + | |
5 | + | |
6 | +class TestEmailBlock(TestCase): | |
7 | + | |
8 | + def setUp(self): | |
9 | + self.email_block = EmailBlock() | |
10 | + | |
11 | + def test_html2text_without_br_tag(self): | |
12 | + html = '<a>Hello, world!</a>' | |
13 | + text = self.email_block._html2text(html) | |
14 | + | |
15 | + self.assertEquals(text, 'Hello, world!') | |
16 | + | |
17 | + def test_html2text_with_br_tag(self): | |
18 | + html = '<a>Hello, world</a>!<br><p>Test with br tag</p>!' | |
19 | + text = self.email_block._html2text(html) | |
20 | + | |
21 | + self.assertEquals(text, 'Hello, world!\nTest with br tag!') | |
22 | + | |
23 | + def test_mark_links(self): | |
24 | + html = 'http://test.org/' | |
25 | + text = self.email_block._mark_links(html) | |
26 | + | |
27 | + self.assertEquals(text, '<a target="_blank" href=' + | |
28 | + '"http://test.org/">http://test.org/</a>') | ... | ... |
colab/super_archives/utils/blocks.py