2019-07-12 11:35:40 +02:00
|
|
|
from flask import url_for
|
|
|
|
|
2021-10-12 14:36:47 +02:00
|
|
|
from app.db import Session
|
2019-07-12 11:35:40 +02:00
|
|
|
from app.models import User
|
|
|
|
|
|
|
|
|
|
|
|
def test_unactivated_user_login(flask_client):
|
|
|
|
"""Start with a blank database."""
|
|
|
|
|
|
|
|
# create user, user is not activated
|
|
|
|
User.create(email="a@b.c", password="password", name="Test User")
|
2021-10-12 14:36:47 +02:00
|
|
|
Session.commit()
|
2019-07-12 11:35:40 +02:00
|
|
|
|
|
|
|
r = flask_client.post(
|
|
|
|
url_for("auth.login"),
|
|
|
|
data={"email": "a@b.c", "password": "password"},
|
|
|
|
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):
|
|
|
|
"""Start with a blank database."""
|
|
|
|
|
2019-07-22 17:28:31 +02:00
|
|
|
# create user, user is activated
|
2019-07-12 11:35:40 +02:00
|
|
|
User.create(email="a@b.c", password="password", name="Test User", activated=True)
|
2021-10-12 14:36:47 +02:00
|
|
|
Session.commit()
|
2019-07-12 11:35:40 +02:00
|
|
|
|
|
|
|
r = flask_client.post(
|
|
|
|
url_for("auth.login"),
|
|
|
|
data={"email": "a@b.c", "password": "password"},
|
|
|
|
follow_redirects=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert r.status_code == 200
|
|
|
|
assert b"/auth/logout" in r.data
|