mirror of
https://github.com/logos-co/open-law.git
synced 2025-02-04 19:14:23 +00:00
refactor test util login
This commit is contained in:
parent
627179102b
commit
4b64e44b5c
@ -12,11 +12,11 @@ def test_auth_pages(client):
|
||||
|
||||
def test_login_and_logout(client):
|
||||
# Access to logout view before login should fail.
|
||||
response = login(client)
|
||||
response, _ = login(client)
|
||||
assert b"Login successful." in response.data
|
||||
# Incorrect login credentials should fail.
|
||||
response = login(client, "sam", "wrongpassword")
|
||||
response, _ = login(client, "sam", "wrongpassword")
|
||||
assert b"Wrong user ID or password." in response.data
|
||||
# Correct credentials should login
|
||||
response = login(client)
|
||||
response, _ = login(client)
|
||||
assert b"Login successful." in response.data
|
||||
|
@ -13,9 +13,11 @@ def create(username=TEST_ADMIN_NAME, password=TEST_ADMIN_PASSWORD):
|
||||
|
||||
|
||||
def login(client, username=TEST_ADMIN_NAME, password=TEST_ADMIN_PASSWORD):
|
||||
return client.post(
|
||||
user = User.query.filter_by(username=username).first()
|
||||
response = client.post(
|
||||
"/login", data=dict(user_id=username, password=password), follow_redirects=True
|
||||
)
|
||||
return response, user
|
||||
|
||||
|
||||
def logout(client):
|
||||
|
Loading…
x
Reference in New Issue
Block a user