示例#1
0
def test_html_msg():
    """Html message generated correctly"""

    expected = r"""Content-Type: multipart/alternative;\n?\s*boundary="===============(\d)+=="
MIME-Version: 1.0
Subject: this is the test html subject
From: [email protected]
To: [email protected], [email protected]

--===============(\d)+==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

this is 
 the plain body
--===============(\d)+==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64

PGh0bWw\+aHRtbCB0ZXN0PC9odG1sPg==

--===============(\d)+==--"""

    msg = _generate_mail_msg(
        "*****@*****.**",
        "[email protected], [email protected]",
        "this is the test html subject",
        ["this is \n the plain body", "<html>html test</html>"],
        None,
    )
    assert re.match(expected, msg)
示例#2
0
def test_plain_msg_several_recipients():
    """Plain mail msg with several recipients generated properly"""
    expected = ("Subject: this is the test subject\nFrom: [email protected]\n"
                "To: [email protected],[email protected]\n\nthis is \n the body")
    assert expected == _generate_mail_msg("*****@*****.**",
                                          "[email protected],[email protected]",
                                          "this is the test subject",
                                          "this is \n the body")
示例#3
0
def test_plain_msg():
    """Plain mail msg generated properly"""
    expected = (
        """Subject: this is the test subject\nFrom: [email protected]\nTo: [email protected]\n\nthis is \n the body"""
    )
    assert expected == _generate_mail_msg(
        "*****@*****.**", "*****@*****.**", "this is the test subject", "this is \n the body"
    )