Esempio n. 1
0
def test_respond_attach():
    person = "hello"
    mail = view.respond(locals(),
                        Body="template.txt",
                        From="test@localhost",
                        To="receiver@localhost",
                        Subject='Test body from someone.')

    view.attach(mail,
                locals(),
                'template.html',
                content_type="text/html",
                filename="template.html",
                disposition='attachment')

    assert_equal(len(mail.attachments), 1)

    msg = mail.to_message()
    assert_equal(len(msg.get_payload()), 2)
    assert str(msg)

    mail.clear()

    view.attach(mail, locals(), 'template.html', content_type="text/html")
    assert_equal(len(mail.attachments), 1)

    msg = mail.to_message()
    assert_equal(len(msg.get_payload()), 2)
    assert str(msg)
Esempio n. 2
0
def test_unicode():
    person = u'H\xe9avy M\xe9t\xe5l Un\xeec\xf8d\xe9'
    mail = view.respond(locals(), Html="unicode.html", From="test@localhost", To="receiver@localhost", Subject='Test body from someone.')

    assert str(mail)

    view.attach(mail, locals(), "unicode.html", filename="attached.html")

    assert str(mail)
Esempio n. 3
0
def test_respond_attach():
    person = "hello"
    mail = view.respond(locals(), Body="template.txt", From="test@localhost", To="receiver@localhost", Subject='Test body from someone.')

    view.attach(mail, locals(), 'template.html', content_type="text/html", filename="template.html", disposition='attachment')

    assert_equal(len(mail.attachments), 1)

    msg = mail.to_message()
    assert_equal(len(msg.get_payload()), 2)
    assert str(msg)

    mail.clear()

    view.attach(mail, locals(), 'template.html', content_type="text/html")
    assert_equal(len(mail.attachments), 1)

    msg = mail.to_message()
    assert_equal(len(msg.get_payload()), 2)
    assert str(msg)