|
|
@ -127,6 +127,70 @@ def test_conversion_html_to_text():
|
|
|
|
# If you give nothing, you get nothing in return
|
|
|
|
# If you give nothing, you get nothing in return
|
|
|
|
assert to_html("") == ""
|
|
|
|
assert to_html("") == ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Special case on HR tag
|
|
|
|
|
|
|
|
assert to_html("""
|
|
|
|
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head></head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<p><b>FROM: </b>apprise-test@mydomain.yyy
|
|
|
|
|
|
|
|
<apprise-test@mydomain.yyy></p>
|
|
|
|
|
|
|
|
Hi!<br/>
|
|
|
|
|
|
|
|
How are you?<br/>
|
|
|
|
|
|
|
|
<font color=3D"#FF0000">red font</font>
|
|
|
|
|
|
|
|
<a href=3D"http://www.python.org">link</a> you wanted.<br/>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|
|
|
|
|
|
|
|
""") == "FROM: apprise-test@mydomain.yyy\nHi!\n How are you?\n \
|
|
|
|
|
|
|
|
red font link you wanted."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert to_html("""
|
|
|
|
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head></head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<p><b>FROM: </b>apprise-test@mydomain.yyy
|
|
|
|
|
|
|
|
<apprise-test@mydomain.yyy><hr></p>
|
|
|
|
|
|
|
|
Hi!<br/>
|
|
|
|
|
|
|
|
How are you?<br/>
|
|
|
|
|
|
|
|
<font color=3D"#FF0000">red font</font>
|
|
|
|
|
|
|
|
<a href=3D"http://www.python.org">link</a> you wanted.<br/>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|
|
|
|
|
|
|
|
""") == "FROM: apprise-test@mydomain.yyy\n---\nHi!\n \
|
|
|
|
|
|
|
|
How are you?\n red font link you wanted."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Special case on HR if text is sorrunded by HR tags
|
|
|
|
|
|
|
|
# its created a dict element
|
|
|
|
|
|
|
|
assert to_html("""
|
|
|
|
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head></head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<p><hr><b>FROM: </b>apprise-test@mydomain.yyy
|
|
|
|
|
|
|
|
<apprise-test@mydomain.yyy><hr></p>
|
|
|
|
|
|
|
|
Hi!<br/>
|
|
|
|
|
|
|
|
How are you?<br/>
|
|
|
|
|
|
|
|
<font color=3D"#FF0000">red font</font>
|
|
|
|
|
|
|
|
<a href=3D"http://www.python.org">link</a> you wanted.<br/>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|
|
|
|
|
|
|
|
""") == "---\nFROM: apprise-test@mydomain.yyy\n---\nHi!\n \
|
|
|
|
|
|
|
|
How are you?\n red font link you wanted."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert to_html("""
|
|
|
|
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head></head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
<hr><b>TEST</b><hr>
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
Hi!<br/>
|
|
|
|
|
|
|
|
How are you?<br/>
|
|
|
|
|
|
|
|
<font color=3D"#FF0000">red font</font>
|
|
|
|
|
|
|
|
<a href=3D"http://www.python.org">link</a> you wanted.<br/>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|
|
|
|
|
|
|
|
""") == "---\nTEST\n---\nHi!\n How are you?\n red font link you \
|
|
|
|
|
|
|
|
wanted."
|
|
|
|
|
|
|
|
|
|
|
|
with pytest.raises(TypeError):
|
|
|
|
with pytest.raises(TypeError):
|
|
|
|
# Invalid input
|
|
|
|
# Invalid input
|
|
|
|
assert to_html(None)
|
|
|
|
assert to_html(None)
|
|
|
|