Solution: Record e-mail sending


mock-method/test_app.py
import app
import re

def test_app(monkeypatch):
    aut = app.app.test_client()

    rv = aut.get('/')
    assert rv.status == '200 OK'
    assert 'here'}]

    rv = aut.get('/verify/{email}/{code}'.format(email = email, code = 'other' ))
    assert rv.status == '200 OK'
    assert 'FAILED' in str(rv.data)

    match = re.search(r'/(\d\.\d+)"', messages[0]['html'])
    if match:
        code = match.group(1)
    print(code)

    messages = []
    rv = aut.get('/verify/{email}/{code}'.format(email = email, code = code ))
    assert rv.status == '200 OK'
    assert 'OK' in str(rv.data)

    assert messages == [{'to': email, 'subject': 'Welcome!', 'html': ''}]