| 37 | |
| 38 | |
| 39 | def test_login(client, auth): |
| 40 | # test that viewing the page renders without template errors |
| 41 | assert client.get("/auth/login").status_code == 200 |
| 42 | |
| 43 | # test that successful login redirects to the index page |
| 44 | response = auth.login() |
| 45 | assert response.headers["Location"] == "/" |
| 46 | |
| 47 | # login request set the user_id in the session |
| 48 | # check that the user is loaded from the session |
| 49 | with client: |
| 50 | client.get("/") |
| 51 | assert session["user_id"] == 1 |
| 52 | assert g.user["username"] == "test" |
| 53 | |
| 54 | |
| 55 | @pytest.mark.parametrize( |