Esempio n. 1
0
def test_bad_header_subject_trailing_whitespace():
    mail = Mail(**test_mail_options)
    msg = Message(subject="testing\r\n\t",
                  body="testing",
                  recipients=["*****@*****.**"])

    with pytest.raises(BadHeaderError):
        mail.send(msg)
Esempio n. 2
0
def test_bad_header_with_a_newline():
    mail = Mail(**test_mail_options)
    msg = Message(subject="\ntesting\r\ntesting",
                  body="testing",
                  recipients=["*****@*****.**"])

    with pytest.raises(BadHeaderError):
        mail.send(msg)
Esempio n. 3
0
def test_message_ascii_attachments_config():
    mail = Mail(**test_mail_options)
    mail.mail_ascii_attachments = True
    msg = Message(sender="*****@*****.**",
                  subject="subject",
                  recipients=["*****@*****.**"])
    mail.send(msg)
    assert msg.ascii_attachments
Esempio n. 4
0
def test_bad_header_subject_with_no_trailing_whitespace():
    """
    Exercises line `if linenum > 0 and line[0] not in '\t ':`

    This is a bit of a strange test but we aren't changing the bad_header check from flask_mail
    """
    mail = Mail(**test_mail_options)
    msg = Message(subject="testing\r\ntesting",
                  body="testing",
                  recipients=["*****@*****.**"])

    with pytest.raises(BadHeaderError):
        mail.send(msg)
Esempio n. 5
0
def test_mail_send_message():
    mail = Mail(**test_mail_options)
    mail.send = MagicMock()
    mail.send_message(sender="*****@*****.**",
                      recipients=["*****@*****.**"],
                      body="normal ascii text")
    assert mail.send.has_been_called()
Esempio n. 6
0
def test_message_default_sender():
    msg = Message(recipients=["*****@*****.**"])
    msg.body = "normal ascii text"
    mail = Mail(**test_mail_options)
    mail.send(msg)
    assert msg.sender == '*****@*****.**'
Esempio n. 7
0
def test_empty_subject_header():
    mail = Mail(**test_mail_options)
    msg = Message(sender="*****@*****.**", recipients=["*****@*****.**"])
    msg.body = "normal ascii text"
    mail.send(msg)
    assert 'Subject:' not in msg.as_string()