diff --git a/tests/test_auth.py b/tests/test_auth.py index 62f03b1..d33d076 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -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 diff --git a/tests/utils.py b/tests/utils.py index 3d25bec..0cf4789 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -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):