Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/deposit/test_views.py
# Copyright (C) 2021-2022 The Software Heritage developers | # Copyright (C) 2021-2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from base64 import b64encode | from base64 import b64encode | ||||
import pytest | import pytest | ||||
from django.conf import settings | |||||
from swh.web.auth.utils import ADMIN_LIST_DEPOSIT_PERMISSION | from swh.web.auth.utils import ADMIN_LIST_DEPOSIT_PERMISSION | ||||
from swh.web.config import get_config | from swh.web.config import get_config | ||||
from swh.web.tests.helpers import ( | from swh.web.tests.helpers import ( | ||||
check_html_get_response, | check_html_get_response, | ||||
check_http_get_response, | check_http_get_response, | ||||
create_django_permission, | create_django_permission, | ||||
) | ) | ||||
from swh.web.utils import reverse | from swh.web.utils import reverse | ||||
def test_deposit_admin_view_not_available_for_anonymous_user(client): | def test_deposit_admin_view_not_available_for_anonymous_user(client): | ||||
url = reverse("admin-deposit") | url = reverse("admin-deposit") | ||||
resp = check_html_get_response(client, url, status_code=302) | resp = check_html_get_response(client, url, status_code=302) | ||||
assert resp["location"] == reverse("login", query_params={"next": url}) | assert resp["location"] == reverse( | ||||
settings.LOGIN_URL, query_params={"next_path": url} | |||||
) | |||||
@pytest.mark.django_db | @pytest.mark.django_db | ||||
def test_deposit_admin_view_available_for_staff_user(client, staff_user): | def test_deposit_admin_view_available_for_staff_user(client, staff_user): | ||||
client.force_login(staff_user) | client.force_login(staff_user) | ||||
url = reverse("admin-deposit") | url = reverse("admin-deposit") | ||||
check_html_get_response( | check_html_get_response( | ||||
client, url, status_code=200, template_used="deposit-admin.html" | client, url, status_code=200, template_used="deposit-admin.html" | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |