mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 00:48:32 +01:00
32 lines
616 B
Python
32 lines
616 B
Python
import json
|
|
|
|
from flask import url_for
|
|
|
|
from app.models import User
|
|
|
|
|
|
def login(flask_client) -> User:
|
|
# create user, user is activated
|
|
user = User.create(
|
|
email="a@b.c",
|
|
password="password",
|
|
name="Test User",
|
|
activated=True,
|
|
commit=True,
|
|
)
|
|
|
|
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
|
|
|
|
|
|
def pretty(d):
|
|
"""pretty print as json"""
|
|
print(json.dumps(d, indent=2))
|