open-law/tests/utils.py

25 lines
605 B
Python
Raw Normal View History

2023-04-20 13:10:16 +00:00
from app.models import User
TEST_ADMIN_NAME = "bob"
TEST_ADMIN_EMAIL = "bob@test.com"
TEST_ADMIN_PASSWORD = "password"
2023-04-20 13:42:47 +00:00
def create(
2023-04-20 13:10:16 +00:00
username=TEST_ADMIN_NAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD
):
user = User(username=username, email=email)
user.password = password
user.save()
return user.id
def login(client, username=TEST_ADMIN_NAME, password=TEST_ADMIN_PASSWORD):
return client.post(
"/login", data=dict(user_id=username, password=password), follow_redirects=True
)
def logout(client):
return client.get("/logout", follow_redirects=True)