Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_content.py
Show First 20 Lines • Show All 441 Lines • ▼ Show 20 Lines | ): | ||||
origin_url = origin_with_multiple_visits["url"] | origin_url = origin_with_multiple_visits["url"] | ||||
visits = archive_data.origin_visit_get(origin_url) | visits = archive_data.origin_visit_get(origin_url) | ||||
visit = random.choice(visits) | visit = random.choice(visits) | ||||
snapshot = archive_data.snapshot_get(visit["snapshot"]) | snapshot = archive_data.snapshot_get(visit["snapshot"]) | ||||
snapshot_sizes = archive_data.snapshot_count_branches(visit["snapshot"]) | snapshot_sizes = archive_data.snapshot_count_branches(visit["snapshot"]) | ||||
branches, releases, _ = process_snapshot_branches(snapshot) | branches, releases, _ = process_snapshot_branches(snapshot) | ||||
branch_info = random.choice(branches) | branch_info = random.choice(branches) | ||||
directory = archive_data.revision_get(branch_info["revision"])["directory"] | directory = archive_data.revision_get(branch_info["target"])["directory"] | ||||
directory_content = archive_data.directory_ls(directory) | directory_content = archive_data.directory_ls(directory) | ||||
directory_file = random.choice( | directory_file = random.choice( | ||||
[e for e in directory_content if e["type"] == "file"] | [e for e in directory_content if e["type"] == "file"] | ||||
) | ) | ||||
url = reverse( | url = reverse( | ||||
"browse-content", | "browse-content", | ||||
url_args={"query_string": directory_file["checksums"]["sha1"]}, | url_args={"query_string": directory_file["checksums"]["sha1"]}, | ||||
Show All 16 Lines | ): | ||||
assert_contains(resp, f"Branch: <strong>{branch_info['name']}</strong>") | assert_contains(resp, f"Branch: <strong>{branch_info['name']}</strong>") | ||||
cnt_swhid = gen_swhid( | cnt_swhid = gen_swhid( | ||||
ObjectType.CONTENT, | ObjectType.CONTENT, | ||||
directory_file["checksums"]["sha1_git"], | directory_file["checksums"]["sha1_git"], | ||||
metadata={ | metadata={ | ||||
"origin": origin_url, | "origin": origin_url, | ||||
"visit": gen_swhid(ObjectType.SNAPSHOT, snapshot["id"]), | "visit": gen_swhid(ObjectType.SNAPSHOT, snapshot["id"]), | ||||
"anchor": gen_swhid(ObjectType.REVISION, branch_info["revision"]), | "anchor": gen_swhid(ObjectType.REVISION, branch_info["target"]), | ||||
"path": f"/{directory_file['name']}", | "path": f"/{directory_file['name']}", | ||||
}, | }, | ||||
) | ) | ||||
assert_contains(resp, cnt_swhid) | assert_contains(resp, cnt_swhid) | ||||
dir_swhid = gen_swhid( | dir_swhid = gen_swhid( | ||||
ObjectType.DIRECTORY, | ObjectType.DIRECTORY, | ||||
directory, | directory, | ||||
metadata={ | metadata={ | ||||
"origin": origin_url, | "origin": origin_url, | ||||
"visit": gen_swhid(ObjectType.SNAPSHOT, snapshot["id"]), | "visit": gen_swhid(ObjectType.SNAPSHOT, snapshot["id"]), | ||||
"anchor": gen_swhid(ObjectType.REVISION, branch_info["revision"]), | "anchor": gen_swhid(ObjectType.REVISION, branch_info["target"]), | ||||
}, | }, | ||||
) | ) | ||||
assert_contains(resp, dir_swhid) | assert_contains(resp, dir_swhid) | ||||
rev_swhid = gen_swhid( | rev_swhid = gen_swhid( | ||||
ObjectType.REVISION, | ObjectType.REVISION, | ||||
branch_info["revision"], | branch_info["target"], | ||||
metadata={ | metadata={ | ||||
"origin": origin_url, | "origin": origin_url, | ||||
"visit": gen_swhid(ObjectType.SNAPSHOT, snapshot["id"]), | "visit": gen_swhid(ObjectType.SNAPSHOT, snapshot["id"]), | ||||
}, | }, | ||||
) | ) | ||||
assert_contains(resp, rev_swhid) | assert_contains(resp, rev_swhid) | ||||
snp_swhid = gen_swhid( | snp_swhid = gen_swhid( | ||||
▲ Show 20 Lines • Show All 605 Lines • Show Last 20 Lines |