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 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 unknown_release | |||||
from swh.web.tests.utils import check_html_get_response | from swh.web.tests.utils import check_html_get_response | ||||
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( | ||||
Show All 15 Lines | _release_browse_checks( | ||||
client, | client, | ||||
release, | release, | ||||
archive_data, | archive_data, | ||||
origin_url=origin_url, | origin_url=origin_url, | ||||
snapshot_id=snapshot["id"], | snapshot_id=snapshot["id"], | ||||
) | ) | ||||
@given(unknown_release()) | |||||
def test_release_browse_not_found(client, archive_data, unknown_release): | def test_release_browse_not_found(client, archive_data, unknown_release): | ||||
url = reverse("browse-release", url_args={"sha1_git": unknown_release}) | url = reverse("browse-release", url_args={"sha1_git": 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) | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |