takahe/tests/core/test_html.py

22 lines
625 B
Python
Raw Normal View History

2022-11-28 21:34:14 -08:00
from core.html import html_to_plaintext, sanitize_post
2022-11-27 11:09:08 -08:00
def test_html_to_plaintext():
assert html_to_plaintext("<p>Hi!</p>") == "Hi!"
assert html_to_plaintext("<p>Hi!<br>There</p>") == "Hi!\nThere"
assert (
html_to_plaintext("<p>Hi!</p>\n\n<p>How are you?</p>") == "Hi!\n\nHow are you?"
)
assert (
html_to_plaintext("<p>Hi!</p>\n\n<p>How are<br> you?</p><p>today</p>")
== "Hi!\n\nHow are\n you?\n\ntoday"
)
2022-11-28 21:34:14 -08:00
def test_sanitize_post():
assert sanitize_post("<p>Hello!</p>") == "<p>Hello!</p>"
assert sanitize_post("<p>It&#39;s great</p>") == "<p>It&#39;s great</p>"