2023-04-20 13:45:03 +00:00
|
|
|
from tests.utils import login
|
2023-04-20 13:10:16 +00:00
|
|
|
|
|
|
|
TEST_EMAIL = "test@gmail.com"
|
|
|
|
|
|
|
|
|
|
|
|
def test_auth_pages(client):
|
|
|
|
response = client.get("/login")
|
|
|
|
assert response.status_code == 200
|
|
|
|
response = client.get("/logout")
|
|
|
|
assert response.status_code == 302
|
|
|
|
|
|
|
|
|
|
|
|
def test_login_and_logout(client):
|
|
|
|
# Access to logout view before login should fail.
|
2023-04-20 13:42:47 +00:00
|
|
|
response = login(client)
|
2023-04-20 13:10:16 +00:00
|
|
|
assert b"Login successful." in response.data
|
|
|
|
# Incorrect login credentials should fail.
|
|
|
|
response = login(client, "sam", "wrongpassword")
|
|
|
|
assert b"Wrong user ID or password." in response.data
|
|
|
|
# Correct credentials should login
|
2023-04-20 13:42:47 +00:00
|
|
|
response = login(client)
|
2023-04-20 13:10:16 +00:00
|
|
|
assert b"Login successful." in response.data
|