Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_origin.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 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 datetime import datetime, timezone | from datetime import datetime, timezone | ||||
import random | import random | ||||
import re | import re | ||||
import string | import string | ||||
import textwrap | import textwrap | ||||
from django.utils.html import escape | from django.utils.html import escape | ||||
from hypothesis import given | from hypothesis import given | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.identifiers import CONTENT, DIRECTORY, RELEASE, REVISION, SNAPSHOT | |||||
from swh.model.model import ( | from swh.model.model import ( | ||||
Snapshot, | Snapshot, | ||||
SnapshotBranch, | SnapshotBranch, | ||||
TargetType, | TargetType, | ||||
) | ) | ||||
from swh.web.browse.snapshot_context import process_snapshot_branches | from swh.web.browse.snapshot_context import process_snapshot_branches | ||||
from swh.web.common.exc import NotFoundExc | from swh.web.common.exc import NotFoundExc | ||||
from swh.web.common.identifiers import get_swh_persistent_id | from swh.web.common.identifiers import get_swh_persistent_id | ||||
from swh.web.common.utils import ( | from swh.web.common.utils import ( | ||||
reverse, | reverse, | ||||
gen_path_info, | gen_path_info, | ||||
format_utc_iso_date, | format_utc_iso_date, | ||||
parse_timestamp, | parse_timestamp, | ||||
) | ) | ||||
from swh.web.config import get_config | |||||
from swh.web.tests.data import get_content, random_sha1 | from swh.web.tests.data import get_content, random_sha1 | ||||
from swh.web.tests.django_asserts import assert_contains, assert_template_used | from swh.web.tests.django_asserts import assert_contains, assert_template_used | ||||
from swh.web.tests.strategies import ( | from swh.web.tests.strategies import ( | ||||
origin, | origin, | ||||
origin_with_multiple_visits, | origin_with_multiple_visits, | ||||
new_origin, | new_origin, | ||||
new_snapshot, | new_snapshot, | ||||
visit_dates, | visit_dates, | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | def _get_archive_data(visit_idx): | ||||
"content": get_content(dir_file["checksums"]["sha1"]), | "content": get_content(dir_file["checksums"]["sha1"]), | ||||
"visit": origin_visits[visit_idx], | "visit": origin_visits[visit_idx], | ||||
} | } | ||||
tdata = _get_archive_data(-1) | tdata = _get_archive_data(-1) | ||||
_origin_content_view_test_helper( | _origin_content_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | origin_visits[-1], | ||||
tdata["branches"], | tdata["branches"], | ||||
tdata["releases"], | tdata["releases"], | ||||
tdata["root_dir_sha1"], | tdata["root_dir_sha1"], | ||||
tdata["content"], | tdata["content"], | ||||
) | ) | ||||
_origin_content_view_test_helper( | _origin_content_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | origin_visits[-1], | ||||
tdata["branches"], | tdata["branches"], | ||||
tdata["releases"], | tdata["releases"], | ||||
tdata["root_dir_sha1"], | tdata["root_dir_sha1"], | ||||
tdata["content"], | tdata["content"], | ||||
timestamp=tdata["visit"]["date"], | timestamp=tdata["visit"]["date"], | ||||
) | ) | ||||
visit_unix_ts = parse_timestamp(tdata["visit"]["date"]).timestamp() | visit_unix_ts = parse_timestamp(tdata["visit"]["date"]).timestamp() | ||||
visit_unix_ts = int(visit_unix_ts) | visit_unix_ts = int(visit_unix_ts) | ||||
_origin_content_view_test_helper( | _origin_content_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | origin_visits[-1], | ||||
tdata["branches"], | tdata["branches"], | ||||
tdata["releases"], | tdata["releases"], | ||||
tdata["root_dir_sha1"], | tdata["root_dir_sha1"], | ||||
tdata["content"], | tdata["content"], | ||||
timestamp=visit_unix_ts, | timestamp=visit_unix_ts, | ||||
) | ) | ||||
tdata = _get_archive_data(0) | tdata = _get_archive_data(0) | ||||
_origin_content_view_test_helper( | _origin_content_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | origin_visits[0], | ||||
tdata["branches"], | tdata["branches"], | ||||
tdata["releases"], | tdata["releases"], | ||||
tdata["root_dir_sha1"], | tdata["root_dir_sha1"], | ||||
tdata["content"], | tdata["content"], | ||||
visit_id=tdata["visit"]["visit"], | visit_id=tdata["visit"]["visit"], | ||||
) | ) | ||||
@given(origin()) | @given(origin()) | ||||
def test_origin_root_directory_view(client, archive_data, origin): | def test_origin_root_directory_view(client, archive_data, origin): | ||||
origin_visits = archive_data.origin_visit_get(origin["url"]) | origin_visits = archive_data.origin_visit_get(origin["url"]) | ||||
visit = origin_visits[-1] | visit = origin_visits[-1] | ||||
snapshot = archive_data.snapshot_get(visit["snapshot"]) | snapshot = archive_data.snapshot_get(visit["snapshot"]) | ||||
head_rev_id = archive_data.snapshot_get_head(snapshot) | head_rev_id = archive_data.snapshot_get_head(snapshot) | ||||
head_rev = archive_data.revision_get(head_rev_id) | head_rev = archive_data.revision_get(head_rev_id) | ||||
root_dir_sha1 = head_rev["directory"] | root_dir_sha1 = head_rev["directory"] | ||||
dir_content = archive_data.directory_ls(root_dir_sha1) | dir_content = archive_data.directory_ls(root_dir_sha1) | ||||
branches, releases = process_snapshot_branches(snapshot) | branches, releases = process_snapshot_branches(snapshot) | ||||
visit_unix_ts = parse_timestamp(visit["date"]).timestamp() | visit_unix_ts = parse_timestamp(visit["date"]).timestamp() | ||||
visit_unix_ts = int(visit_unix_ts) | visit_unix_ts = int(visit_unix_ts) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, origin, origin_visits, branches, releases, root_dir_sha1, dir_content | client, | ||||
archive_data, | |||||
origin, | |||||
visit, | |||||
branches, | |||||
releases, | |||||
root_dir_sha1, | |||||
dir_content, | |||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
dir_content, | dir_content, | ||||
visit_id=visit["visit"], | visit_id=visit["visit"], | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
dir_content, | dir_content, | ||||
timestamp=visit_unix_ts, | timestamp=visit_unix_ts, | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
dir_content, | dir_content, | ||||
timestamp=visit["date"], | timestamp=visit["date"], | ||||
) | ) | ||||
origin = dict(origin) | origin = dict(origin) | ||||
del origin["type"] | del origin["type"] | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, origin, origin_visits, branches, releases, root_dir_sha1, dir_content | client, | ||||
archive_data, | |||||
origin, | |||||
visit, | |||||
branches, | |||||
releases, | |||||
root_dir_sha1, | |||||
dir_content, | |||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
dir_content, | dir_content, | ||||
visit_id=visit["visit"], | visit_id=visit["visit"], | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
dir_content, | dir_content, | ||||
timestamp=visit_unix_ts, | timestamp=visit_unix_ts, | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
dir_content, | dir_content, | ||||
timestamp=visit["date"], | timestamp=visit["date"], | ||||
) | ) | ||||
Show All 17 Lines | if len(subdirs) == 0: | ||||
return | return | ||||
subdir = random.choice(subdirs) | subdir = random.choice(subdirs) | ||||
subdir_content = archive_data.directory_ls(subdir["target"]) | subdir_content = archive_data.directory_ls(subdir["target"]) | ||||
subdir_path = subdir["name"] | subdir_path = subdir["name"] | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
subdir_content, | subdir_content, | ||||
path=subdir_path, | path=subdir_path, | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
subdir_content, | subdir_content, | ||||
path=subdir_path, | path=subdir_path, | ||||
visit_id=visit["visit"], | visit_id=visit["visit"], | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
subdir_content, | subdir_content, | ||||
path=subdir_path, | path=subdir_path, | ||||
timestamp=visit_unix_ts, | timestamp=visit_unix_ts, | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
subdir_content, | subdir_content, | ||||
path=subdir_path, | path=subdir_path, | ||||
timestamp=visit["date"], | timestamp=visit["date"], | ||||
) | ) | ||||
origin = dict(origin) | origin = dict(origin) | ||||
del origin["type"] | del origin["type"] | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
subdir_content, | subdir_content, | ||||
path=subdir_path, | path=subdir_path, | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
subdir_content, | subdir_content, | ||||
path=subdir_path, | path=subdir_path, | ||||
visit_id=visit["visit"], | visit_id=visit["visit"], | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
subdir_content, | subdir_content, | ||||
path=subdir_path, | path=subdir_path, | ||||
timestamp=visit_unix_ts, | timestamp=visit_unix_ts, | ||||
) | ) | ||||
_origin_directory_view_test_helper( | _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin, | origin, | ||||
origin_visits, | visit, | ||||
branches, | branches, | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
subdir_content, | subdir_content, | ||||
path=subdir_path, | path=subdir_path, | ||||
timestamp=visit["date"], | timestamp=visit["date"], | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | def test_origin_empty_snapshot(client, mocker, origin): | ||||
assert re.search("snapshot.*is empty", resp_content) | assert re.search("snapshot.*is empty", resp_content) | ||||
assert not re.search("swh-tr-link", resp_content) | assert not re.search("swh-tr-link", resp_content) | ||||
assert mock_get_origin_visit_snapshot.called | assert mock_get_origin_visit_snapshot.called | ||||
assert mock_service.lookup_snapshot_sizes.called | assert mock_service.lookup_snapshot_sizes.called | ||||
@given(origin_with_releases()) | @given(origin_with_releases()) | ||||
def test_origin_release_browse(client, archive_data, origin): | def test_origin_release_browse(client, archive_data, origin): | ||||
# for swh.web.browse.snapshot_context.get_snapshot_content to only return one branch | |||||
config = get_config() | |||||
snapshot_max_size = int(config["snapshot_content_max_size"]) | |||||
config["snapshot_content_max_size"] = 1 | |||||
try: | |||||
snapshot = archive_data.snapshot_get_latest(origin["url"]) | snapshot = archive_data.snapshot_get_latest(origin["url"]) | ||||
release = [ | release = [ | ||||
b for b in snapshot["branches"].values() if b["target_type"] == "release" | b for b in snapshot["branches"].values() if b["target_type"] == "release" | ||||
][-1] | ][-1] | ||||
release_data = archive_data.release_get(release["target"]) | release_data = archive_data.release_get(release["target"]) | ||||
revision_data = archive_data.revision_get(release_data["target"]) | |||||
url = reverse( | url = reverse( | ||||
"browse-origin-directory", | "browse-origin-directory", | ||||
query_params={"origin_url": origin["url"], "release": release_data["name"]}, | query_params={"origin_url": origin["url"], "release": release_data["name"]}, | ||||
) | ) | ||||
resp = client.get(url) | resp = client.get(url) | ||||
assert resp.status_code == 200 | assert resp.status_code == 200 | ||||
assert_contains(resp, release_data["name"]) | assert_contains(resp, release_data["name"]) | ||||
assert_contains(resp, release["target"]) | assert_contains(resp, release["target"]) | ||||
finally: | |||||
config["snapshot_content_max_size"] = snapshot_max_size | swhid_context = { | ||||
"origin": origin["url"], | |||||
"visit": get_swh_persistent_id(SNAPSHOT, snapshot["id"]), | |||||
"anchor": get_swh_persistent_id(RELEASE, release_data["id"]), | |||||
"path": f"/", | |||||
} | |||||
swh_dir_id = get_swh_persistent_id( | |||||
DIRECTORY, revision_data["directory"], metadata=swhid_context | |||||
) | |||||
swh_dir_id_url = reverse("browse-swh-id", url_args={"swh_id": swh_dir_id}) | |||||
assert_contains(resp, swh_dir_id) | |||||
assert_contains(resp, swh_dir_id_url) | |||||
@given(origin_with_releases()) | @given(origin_with_releases()) | ||||
def test_origin_release_browse_not_found(client, origin): | def test_origin_release_browse_not_found(client, origin): | ||||
invalid_release_name = "swh-foo-bar" | invalid_release_name = "swh-foo-bar" | ||||
url = reverse( | url = reverse( | ||||
"browse-origin-directory", | "browse-origin-directory", | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | ): | ||||
assert resp.status_code == 400 | assert resp.status_code == 400 | ||||
assert_contains( | assert_contains( | ||||
resp, "An origin URL must be provided as query parameter.", status_code=400 | resp, "An origin URL must be provided as query parameter.", status_code=400 | ||||
) | ) | ||||
def _origin_content_view_test_helper( | def _origin_content_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin_info, | origin_info, | ||||
origin_visits, | origin_visit, | ||||
origin_branches, | origin_branches, | ||||
origin_releases, | origin_releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
content, | content, | ||||
visit_id=None, | visit_id=None, | ||||
timestamp=None, | timestamp=None, | ||||
): | ): | ||||
content_path = "/".join(content["path"].split("/")[1:]) | content_path = "/".join(content["path"].split("/")[1:]) | ||||
if not visit_id: | if not visit_id: | ||||
visit_id = origin_visits[-1]["visit"] | visit_id = origin_visit["visit"] | ||||
query_params = {"origin_url": origin_info["url"], "path": content_path} | query_params = {"origin_url": origin_info["url"], "path": content_path} | ||||
if timestamp: | if timestamp: | ||||
query_params["timestamp"] = timestamp | query_params["timestamp"] = timestamp | ||||
if visit_id: | if visit_id: | ||||
query_params["visit_id"] = visit_id | query_params["visit_id"] = visit_id | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | assert_contains( | ||||
% (escape(origin_releases_url), len(origin_releases)), | % (escape(origin_releases_url), len(origin_releases)), | ||||
) | ) | ||||
assert_contains(resp, '<li class="swh-branch">', count=len(origin_branches)) | assert_contains(resp, '<li class="swh-branch">', count=len(origin_branches)) | ||||
query_params["path"] = content_path | query_params["path"] = content_path | ||||
for branch in origin_branches: | for branch in origin_branches: | ||||
query_params["branch"] = branch["name"] | |||||
root_dir_branch_url = reverse( | root_dir_branch_url = reverse( | ||||
"browse-origin-content", query_params=query_params | "browse-origin-content", | ||||
query_params={"branch": branch["name"], **query_params}, | |||||
) | ) | ||||
assert_contains(resp, '<a href="%s">' % root_dir_branch_url) | assert_contains(resp, '<a href="%s">' % root_dir_branch_url) | ||||
assert_contains(resp, '<li class="swh-release">', count=len(origin_releases)) | assert_contains(resp, '<li class="swh-release">', count=len(origin_releases)) | ||||
query_params["branch"] = None | query_params["branch"] = None | ||||
for release in origin_releases: | for release in origin_releases: | ||||
query_params["release"] = release["name"] | |||||
root_dir_release_url = reverse( | root_dir_release_url = reverse( | ||||
"browse-origin-content", query_params=query_params | "browse-origin-content", | ||||
query_params={"release": release["name"], **query_params}, | |||||
) | ) | ||||
assert_contains(resp, '<a href="%s">' % root_dir_release_url) | assert_contains(resp, '<a href="%s">' % root_dir_release_url) | ||||
url = reverse("browse-origin-content", query_params=query_params) | url = reverse("browse-origin-content", query_params=query_params) | ||||
resp = client.get(url) | resp = client.get(url) | ||||
assert resp.status_code == 200 | assert resp.status_code == 200 | ||||
assert_template_used(resp, "browse/content.html") | assert_template_used(resp, "browse/content.html") | ||||
swh_cnt_id = get_swh_persistent_id("content", content["sha1_git"]) | snapshot = archive_data.snapshot_get(origin_visit["snapshot"]) | ||||
head_rev_id = archive_data.snapshot_get_head(snapshot) | |||||
swhid_context = { | |||||
"origin": origin_info["url"], | |||||
"visit": get_swh_persistent_id(SNAPSHOT, snapshot["id"]), | |||||
"anchor": get_swh_persistent_id(REVISION, head_rev_id), | |||||
"path": f"/{content_path}", | |||||
} | |||||
swh_cnt_id = get_swh_persistent_id( | |||||
CONTENT, content["sha1_git"], metadata=swhid_context | |||||
) | |||||
swh_cnt_id_url = reverse("browse-swh-id", url_args={"swh_id": swh_cnt_id}) | swh_cnt_id_url = reverse("browse-swh-id", url_args={"swh_id": swh_cnt_id}) | ||||
assert_contains(resp, swh_cnt_id) | assert_contains(resp, swh_cnt_id) | ||||
assert_contains(resp, swh_cnt_id_url) | assert_contains(resp, swh_cnt_id_url) | ||||
assert_contains(resp, "swh-take-new-snapshot") | assert_contains(resp, "swh-take-new-snapshot") | ||||
_check_origin_view_title(resp, origin_info["url"], "content") | _check_origin_view_title(resp, origin_info["url"], "content") | ||||
def _origin_directory_view_test_helper( | def _origin_directory_view_test_helper( | ||||
client, | client, | ||||
archive_data, | |||||
origin_info, | origin_info, | ||||
origin_visits, | origin_visit, | ||||
origin_branches, | origin_branches, | ||||
origin_releases, | origin_releases, | ||||
root_directory_sha1, | root_directory_sha1, | ||||
directory_entries, | directory_entries, | ||||
visit_id=None, | visit_id=None, | ||||
timestamp=None, | timestamp=None, | ||||
path=None, | path=None, | ||||
): | ): | ||||
dirs = [e for e in directory_entries if e["type"] in ("dir", "rev")] | dirs = [e for e in directory_entries if e["type"] in ("dir", "rev")] | ||||
files = [e for e in directory_entries if e["type"] == "file"] | files = [e for e in directory_entries if e["type"] == "file"] | ||||
if not visit_id: | if not visit_id: | ||||
visit_id = origin_visits[-1]["visit"] | visit_id = origin_visit["visit"] | ||||
query_params = {"origin_url": origin_info["url"]} | query_params = {"origin_url": origin_info["url"]} | ||||
if timestamp: | if timestamp: | ||||
query_params["timestamp"] = timestamp | query_params["timestamp"] = timestamp | ||||
else: | else: | ||||
query_params["visit_id"] = visit_id | query_params["visit_id"] = visit_id | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | for release in origin_releases: | ||||
"browse-origin-directory", query_params=query_params | "browse-origin-directory", query_params=query_params | ||||
) | ) | ||||
assert_contains(resp, '<a href="%s">' % root_dir_release_url) | assert_contains(resp, '<a href="%s">' % root_dir_release_url) | ||||
assert_contains(resp, "vault-cook-directory") | assert_contains(resp, "vault-cook-directory") | ||||
assert_contains(resp, "vault-cook-revision") | assert_contains(resp, "vault-cook-revision") | ||||
swh_dir_id = get_swh_persistent_id("directory", directory_entries[0]["dir_id"]) | snapshot = archive_data.snapshot_get(origin_visit["snapshot"]) | ||||
head_rev_id = archive_data.snapshot_get_head(snapshot) | |||||
swhid_context = { | |||||
"origin": origin_info["url"], | |||||
"visit": get_swh_persistent_id(SNAPSHOT, snapshot["id"]), | |||||
"anchor": get_swh_persistent_id(REVISION, head_rev_id), | |||||
"path": f"/{path}" if path else "/", | |||||
} | |||||
swh_dir_id = get_swh_persistent_id( | |||||
DIRECTORY, directory_entries[0]["dir_id"], metadata=swhid_context | |||||
) | |||||
swh_dir_id_url = reverse("browse-swh-id", url_args={"swh_id": swh_dir_id}) | swh_dir_id_url = reverse("browse-swh-id", url_args={"swh_id": swh_dir_id}) | ||||
assert_contains(resp, swh_dir_id) | assert_contains(resp, swh_dir_id) | ||||
assert_contains(resp, swh_dir_id_url) | assert_contains(resp, swh_dir_id_url) | ||||
assert_contains(resp, "swh-take-new-snapshot") | assert_contains(resp, "swh-take-new-snapshot") | ||||
_check_origin_view_title(resp, origin_info["url"], "directory") | _check_origin_view_title(resp, origin_info["url"], "directory") | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |