Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_directory.py
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | def test_directory_origin_snapshot_branch_browse(client, archive_data, origin): | ||||
snp_swhid = gen_swhid( | snp_swhid = gen_swhid( | ||||
SNAPSHOT, snapshot["id"], metadata={"origin": origin["url"],}, | SNAPSHOT, snapshot["id"], metadata={"origin": origin["url"],}, | ||||
) | ) | ||||
assert_contains(resp, snp_swhid) | assert_contains(resp, snp_swhid) | ||||
@given(origin_with_multiple_visits()) | @given(origin_with_multiple_visits()) | ||||
def test_content_origin_snapshot_release_browse(client, archive_data, origin): | def test_drectory_origin_snapshot_release_browse(client, archive_data, origin): | ||||
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) | ||||
release_info = random.choice(releases) | release_info = random.choice(releases) | ||||
directory = release_info["directory"] | directory = release_info["directory"] | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | def test_drectory_origin_snapshot_release_browse(client, archive_data, origin): | ||||
assert_contains(resp, rel_swhid) | assert_contains(resp, rel_swhid) | ||||
snp_swhid = gen_swhid( | snp_swhid = gen_swhid( | ||||
SNAPSHOT, snapshot["id"], metadata={"origin": origin["url"],}, | SNAPSHOT, snapshot["id"], metadata={"origin": origin["url"],}, | ||||
) | ) | ||||
assert_contains(resp, snp_swhid) | assert_contains(resp, snp_swhid) | ||||
@given(origin_with_multiple_visits()) | |||||
def test_directory_origin_snapshot_revision_browse(client, archive_data, origin): | |||||
visits = archive_data.origin_visit_get(origin["url"]) | |||||
visit = random.choice(visits) | |||||
snapshot = archive_data.snapshot_get(visit["snapshot"]) | |||||
branches, releases, _ = process_snapshot_branches(snapshot) | |||||
branch_info = random.choice(branches) | |||||
directory = archive_data.revision_get(branch_info["revision"])["directory"] | |||||
directory_content = archive_data.directory_ls(directory) | |||||
directory_subdir = random.choice( | |||||
[e for e in directory_content if e["type"] == "dir"] | |||||
) | |||||
url = reverse( | |||||
"browse-directory", | |||||
url_args={"sha1_git": directory}, | |||||
query_params={ | |||||
"origin_url": origin["url"], | |||||
"snapshot": snapshot["id"], | |||||
"revision": branch_info["revision"], | |||||
"path": directory_subdir["name"], | |||||
}, | |||||
) | |||||
resp = check_html_get_response( | |||||
client, url, status_code=200, template_used="browse/directory.html" | |||||
) | |||||
assert_contains(resp, f"Revision: <strong>{branch_info['revision']}</strong>") | |||||
def _check_origin_snapshot_related_html( | def _check_origin_snapshot_related_html( | ||||
resp, origin, snapshot, snapshot_sizes, branches, releases | resp, origin, snapshot, snapshot_sizes, branches, releases | ||||
): | ): | ||||
browse_origin_url = reverse( | browse_origin_url = reverse( | ||||
"browse-origin", query_params={"origin_url": origin["url"]} | "browse-origin", query_params={"origin_url": origin["url"]} | ||||
) | ) | ||||
assert_contains(resp, f'href="{browse_origin_url}"') | assert_contains(resp, f'href="{browse_origin_url}"') | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |