From d2cc6e101ddd0beae7a8120b2568a01ec894c657 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 4 Jul 2023 17:14:34 +0200 Subject: [PATCH] Minimal user_dashboard tests --- umap/tests/test_views.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/umap/tests/test_views.py b/umap/tests/test_views.py index fc05b4b4..8adb8ebf 100644 --- a/umap/tests/test_views.py +++ b/umap/tests/test_views.py @@ -240,3 +240,22 @@ def test_change_user_slug(client, user, settings): settings.USER_URL_FIELD = "pk" response = client.get(reverse("home")) assert f"/en/user/{user.pk}/" in response.content.decode() + + +@pytest.mark.django_db +def test_user_dashboard_is_restricted_to_logged_in(client): + response = client.get(reverse("user_dashboard")) + assert response.status_code == 302 + assert response["Location"] == "/en/login/?next=/en/me" + + +@pytest.mark.django_db +def test_user_dashboard_display_user_maps(client, map): + client.login(username=map.owner.username, password="123123") + response = client.get(reverse("user_dashboard")) + assert response.status_code == 200 + body = response.content.decode() + assert map.name in body + assert f"{map.get_absolute_url()}?edit" in body + assert f"{map.get_absolute_url()}?onLoadPanel=share" in body + assert f"{map.get_absolute_url()}?download" in body