mirror of https://github.com/logos-co/open-law.git
fix auth tests
This commit is contained in:
parent
806dd8a706
commit
f0de4a1f32
|
@ -15,7 +15,7 @@ def test_login_and_logout(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", create_user_if_not_exists=False)
|
||||
assert b"Wrong user ID or password." in response.data
|
||||
# Correct credentials should login
|
||||
response, _ = login(client)
|
||||
|
|
|
@ -21,9 +21,14 @@ def create(username=TEST_ADMIN_NAME, password=TEST_ADMIN_PASSWORD):
|
|||
return user
|
||||
|
||||
|
||||
def login(client, username=TEST_ADMIN_NAME, password=TEST_ADMIN_PASSWORD):
|
||||
def login(
|
||||
client,
|
||||
username=TEST_ADMIN_NAME,
|
||||
password=TEST_ADMIN_PASSWORD,
|
||||
create_user_if_not_exists=True,
|
||||
):
|
||||
user = m.User.query.filter_by(username=username).first()
|
||||
if not user:
|
||||
if create_user_if_not_exists and not user:
|
||||
user = create(username, password)
|
||||
|
||||
response = client.post(
|
||||
|
|
Loading…
Reference in New Issue