http2smtp/tests/test_message.py

31 lines
1.1 KiB
Python

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 = '<html><body><p>This is the body of the <strong>html</strong> e-mail.</p></body></html>'
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