from http2smtp.models import Email from http2smtp.message import build_message def test_build_message_html(): """Test building a message with an HTML body""" subject = 'This is a test e-mail' html_body = '
This is the body of the html e-mail.
' email = Email(from_email='test@example.com', to_email='another@example.com', subject=subject, html_body=html_body, password='dfsghasdf') message = build_message(email) assert message.subject == subject assert message.body == html_body assert message.alternative_body == 'This is the body of the html e-mail.' def test_build_message_text(): """Test building a message with a plain text body""" subject = 'This is a test e-mail' text_body = 'This is the body of the text e-mail.' email = Email(from_email='test@example.com', to_email='another@example.com', subject=subject, text_body=text_body, password='fghfhergsdf') message = build_message(email) assert message.subject == subject assert message.body == text_body assert message.alternative_body is None