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 origin_with_releases, release, unknown_release | from swh.web.tests.strategies import release, unknown_release | ||||
from swh.web.tests.utils import check_html_get_response | from swh.web.tests.utils import check_html_get_response | ||||
@given(release()) | @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) | ||||
@given(origin_with_releases()) | def test_release_browse_with_origin_snapshot( | ||||
def test_release_browse_with_origin_snapshot(client, archive_data, origin): | client, archive_data, origin_with_releases | ||||
snapshot = archive_data.snapshot_get_latest(origin["url"]) | ): | ||||
origin_url = origin_with_releases["url"] | |||||
snapshot = archive_data.snapshot_get_latest(origin_url) | |||||
release = random.choice( | release = random.choice( | ||||
[ | [ | ||||
b["target"] | b["target"] | ||||
for b in snapshot["branches"].values() | for b in snapshot["branches"].values() | ||||
if b["target_type"] == "release" | if b["target_type"] == "release" | ||||
] | ] | ||||
) | ) | ||||
_release_browse_checks(client, release, archive_data, origin_url=origin["url"]) | _release_browse_checks(client, release, archive_data, origin_url=origin_url) | ||||
_release_browse_checks(client, release, archive_data, snapshot_id=snapshot["id"]) | _release_browse_checks(client, release, archive_data, snapshot_id=snapshot["id"]) | ||||
_release_browse_checks( | _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()) | @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}) | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |