open-law/tests/test_auth.py

23 lines
696 B
Python
Raw Normal View History

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-24 08:29:05 +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.
2023-04-24 08:29:05 +00:00
response, _ = login(client, "sam", "wrongpassword")
2023-04-20 13:10:16 +00:00
assert b"Wrong user ID or password." in response.data
# Correct credentials should login
2023-04-24 08:29:05 +00:00
response, _ = login(client)
2023-04-20 13:10:16 +00:00
assert b"Login successful." in response.data