app-MAIL-temp/tests/auth/test_login.py

36 lines
846 B
Python
Raw Normal View History

2019-07-12 11:35:40 +02:00
from flask import url_for
from app.db import Session
from tests.utils import create_new_user
2019-07-12 11:35:40 +02:00
def test_unactivated_user_login(flask_client):
user = create_new_user()
user.activated = False
Session.commit()
2019-07-12 11:35:40 +02:00
r = flask_client.post(
url_for("auth.login"),
data={"email": user.email, "password": "password"},
2019-07-12 11:35:40 +02:00
follow_redirects=True,
)
assert r.status_code == 200
assert (
b"Please check your inbox for the activation email. You can also have this email re-sent"
in r.data
)
def test_activated_user_login(flask_client):
user = create_new_user()
2019-07-12 11:35:40 +02:00
r = flask_client.post(
url_for("auth.login"),
data={"email": user.email, "password": "password"},
2019-07-12 11:35:40 +02:00
follow_redirects=True,
)
assert r.status_code == 200
assert b"/auth/logout" in r.data