Coverage for modules/box__default/dashboard/tests/test_dashboard.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2This file (test_login.py) contains the functional tests for
3the `login` blueprint.
5These tests use GETs and POSTs to different endpoints to check
6for the proper behavior of the `login` blueprint.
7"""
8import pytest
9from flask import request
10from flask import url_for
13class TestDashboardInvalidAccess:
14 """
15 Test all dashboard routes for correct user authentication
16 """
18 routes_get = [
19 "/dashboard/",
20 ]
22 @pytest.mark.parametrize("route", routes_get)
23 def test_redirect_if_not_logged_in_get(self, test_client, route, auth):
24 auth.logout()
25 response = test_client.get(route, follow_redirects=True)
27 assert response.status_code == 200
28 assert request.path == url_for("auth.login")
30 @pytest.mark.usefixtures("login_unconfirmed_user")
31 @pytest.mark.parametrize("route", routes_get)
32 def test_redirect_if_email_not_confirmed(self, test_client, route):
33 response = test_client.get(route, follow_redirects=True)
35 assert response.status_code == 200
36 assert request.path == url_for("auth.unconfirmed")
39@pytest.mark.usefixtures("login_non_admin_user")
40class TestDashboardEndpoints:
41 def test_confirmed_user_can_view_dashboard(self, test_client):
42 response = test_client.get("/dashboard/", follow_redirects=True)
44 assert response.status_code == 200
45 assert b"Control panel" in response.data
46 assert b"Notif test" in response.data