from ows_text_campaigns.campaigns.message import PreparedMessage class TestPreparedMessage: def test_empty_and_whitespace_lines_removed_in_output(self) -> None: html = "

Line1


Line2

" msg = PreparedMessage(html) sms = msg.to_sms() whatsapp = msg.to_whatsapp() expected = "Line1\nLine2" assert sms == expected assert whatsapp == expected def test_nested_tags_formatting(self) -> None: html = "bold and italic" msg = PreparedMessage(html) result = msg.to_whatsapp() assert result == "*bold and italic*" def test_removes_on_event_attributes_and_javascript_href(self) -> None: html = "

Click me

link" msg = PreparedMessage(html) expected = "Click me\nlink" assert msg.to_sms() == expected assert msg.to_whatsapp() == expected def test_to_sms_clean_removes_disallowed_tags(self) -> None: html = "
Hello World !
" msg = PreparedMessage(html) result = msg.to_sms() assert result == "Hello World !" def test_to_whatsapp_clean_removes_disallowed_tags(self) -> None: html = "
Hello World !
" msg = PreparedMessage(html) result = msg.to_whatsapp() assert result == "Hello *World* !" def test_to_sms_br_and_p_conversion(self) -> None: html = "Line1
Line2

Paragraph

End" msg = PreparedMessage(html) result = msg.to_sms() assert result == "Line1\nLine2Paragraph\nEnd" def test_to_whatsapp_br_and_p_conversion(self) -> None: html = "Line1
Line2

Paragraph

End" msg = PreparedMessage(html) result = msg.to_whatsapp() assert result == "Line1\nLine2Paragraph\nEnd" def test_to_whatsapp_formatting(self) -> None: html = "bold italic strike code
preformatted
" msg = PreparedMessage(html) result = msg.to_whatsapp() assert result == "*bold* _italic_ ~strike~ `code` ```\npreformatted\n```" def test_to_whatsapp_links(self) -> None: html = 'Example and no href' msg = PreparedMessage(html) result = msg.to_whatsapp() assert result == "https://example.com and no href" def test_to_whatsapp_removes_all_tags(self) -> None: html = "bold and italic tag" msg = PreparedMessage(html) result = msg.to_whatsapp() assert result == "*bold and italic* tag" def test_to_sms_removes_all_tags(self) -> None: html = "bold italic link" msg = PreparedMessage(html) result = msg.to_sms() assert result == "bold italic link"