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

## 24 statements

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"""

2 This file (test_login.py) contains the functional tests for

3 the `login` blueprint.

4

5 These tests use GETs and POSTs to different endpoints to check

6 for the proper behavior of the `login` blueprint.

7"""

8 import pytest

9 from flask import request

10 from flask import url_for

11

12

13 class TestDashboardInvalidAccess:

14 """

15 Test all dashboard routes for correct user authentication

16 """

17

18 routes_get = [

19 "/dashboard/",

20 ]

21

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)

26

27 assert response.status_code == 200

28 assert request.path == url_for("auth.login")

29

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)

34

35 assert response.status_code == 200

36 assert request.path == url_for("auth.unconfirmed")

37

38

39@pytest.mark.usefixtures("login_non_admin_user")

40 class TestDashboardEndpoints:

41 def test_confirmed_user_can_view_dashboard(self, test_client):

42 response = test_client.get("/dashboard/", follow_redirects=True)

43

44 assert response.status_code == 200

45 assert b"Control panel" in response.data

46 assert b"Notif test" in response.data