Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_release.py
# Copyright (C) 2018-2021 The Software Heritage developers | # Copyright (C) 2018-2021 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 | ||||
import random | import random | ||||
from hypothesis import given | from hypothesis import given | ||||
from django.utils.html import escape | from django.utils.html import escape | ||||
from swh.model.swhids import ObjectType | from swh.model.swhids import ObjectType | ||||
from swh.web.common.identifiers import gen_swhid | from swh.web.common.identifiers import gen_swhid | ||||
from swh.web.common.utils import format_utc_iso_date, reverse | from swh.web.common.utils import format_utc_iso_date, reverse | ||||
from swh.web.tests.django_asserts import assert_contains | from swh.web.tests.django_asserts import assert_contains | ||||
from swh.web.tests.strategies import release, unknown_release | from swh.web.tests.strategies import unknown_release | ||||
from swh.web.tests.utils import check_html_get_response | from swh.web.tests.utils import check_html_get_response | ||||
@given(release()) | |||||
def test_release_browse(client, archive_data, release): | def test_release_browse(client, archive_data, release): | ||||
_release_browse_checks(client, release, archive_data) | _release_browse_checks(client, release, archive_data) | ||||
def test_release_browse_with_origin_snapshot( | def test_release_browse_with_origin_snapshot( | ||||
client, archive_data, origin_with_releases | client, archive_data, origin_with_releases | ||||
): | ): | ||||
origin_url = origin_with_releases["url"] | origin_url = origin_with_releases["url"] | ||||
Show All 23 Lines | def test_release_browse_not_found(client, archive_data, unknown_release): | ||||
resp = check_html_get_response( | resp = check_html_get_response( | ||||
client, url, status_code=404, template_used="error.html" | client, url, status_code=404, template_used="error.html" | ||||
) | ) | ||||
err_msg = "Release with sha1_git %s not found" % unknown_release | err_msg = "Release with sha1_git %s not found" % unknown_release | ||||
assert_contains(resp, err_msg, status_code=404) | assert_contains(resp, err_msg, status_code=404) | ||||
@given(release()) | |||||
def test_release_uppercase(client, release): | def test_release_uppercase(client, release): | ||||
url = reverse( | url = reverse( | ||||
"browse-release-uppercase-checksum", url_args={"sha1_git": release.upper()} | "browse-release-uppercase-checksum", url_args={"sha1_git": release.upper()} | ||||
) | ) | ||||
resp = check_html_get_response(client, url, status_code=302) | resp = check_html_get_response(client, url, status_code=302) | ||||
redirect_url = reverse("browse-release", url_args={"sha1_git": release}) | redirect_url = reverse("browse-release", url_args={"sha1_git": release}) | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |