Example #1
0
def test_set_body_and_get_body():
    me = NoopMassEmail()
    msg = '<h1>Hello!</h1>'

    me.set_body(msg)

    assert me.get_body().get(MIMETYPE_HTML) == msg
    assert me.get_body(mimetype=MIMETYPE_HTML) == msg

    with pytest.raises(AttributeError) as e:
        me.get_body(mimetype=MIMETYPE_TEXT)

    assert 'mimetype' in str(e.value)
Example #2
0
def test_set_body_and_get_body():
    me = NoopMassEmail()
    msg = '<h1>Hello!</h1>'

    me.set_body(msg)

    assert me.get_body().get(MIMETYPE_HTML) == msg
    assert me.get_body(mimetype=MIMETYPE_HTML) == msg

    with pytest.raises(AttributeError) as e:
        me.get_body(mimetype=MIMETYPE_TEXT)

    assert 'mimetype' in str(e.value)
Example #3
0
def test_set_body_with_mimetype():
    '''
    Test that setting a body will set the default (HTML), but this mimetype
    can be overridden with an argument (for, ie. plain text)
    '''
    me = NoopMassEmail()
    msg_text = 'Tester Test'
    msg_html = '<h1>Tester Test HTML</h1>'

    me.set_body(msg_html)
    me.set_body(msg_text, mimetype=MIMETYPE_TEXT)

    assert me.get_body(mimetype=MIMETYPE_HTML) == msg_html
    assert me.get_body(mimetype=MIMETYPE_TEXT) == msg_text
Example #4
0
def test_set_body_with_mimetype():
    '''
    Test that setting a body will set the default (HTML), but this mimetype
    can be overridden with an argument (for, ie. plain text)
    '''
    me = NoopMassEmail()
    msg_text = 'Tester Test'
    msg_html = '<h1>Tester Test HTML</h1>'

    me.set_body(msg_html)
    me.set_body(msg_text, mimetype=MIMETYPE_TEXT)

    assert me.get_body(mimetype=MIMETYPE_HTML) == msg_html
    assert me.get_body(mimetype=MIMETYPE_TEXT) == msg_text