2020-11-15 18:34:13 +00:00
|
|
|
import json
|
|
|
|
|
2019-08-10 15:03:51 +00:00
|
|
|
from flask import url_for
|
|
|
|
|
|
|
|
from app.extensions import db
|
|
|
|
from app.models import User
|
|
|
|
|
|
|
|
|
|
|
|
def login(flask_client) -> User:
|
|
|
|
# create user, user is activated
|
|
|
|
user = User.create(
|
2020-12-31 12:59:03 +00:00
|
|
|
email="a@b.c",
|
|
|
|
password="password",
|
|
|
|
name="Test User",
|
|
|
|
activated=True,
|
|
|
|
commit=True,
|
2019-08-10 15:03:51 +00: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
|
|
|
|
|
|
|
|
return user
|
2020-11-15 18:34:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
def pretty(d):
|
|
|
|
"""pretty print as json"""
|
|
|
|
print(json.dumps(d, indent=2))
|