Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/common/test_identifiers.py
Show First 20 Lines • Show All 417 Lines • ▼ Show 20 Lines | |||||
@given(origin_with_multiple_visits()) | @given(origin_with_multiple_visits()) | ||||
def test_resolve_swhids_snapshot_context(client, archive_data, origin): | def test_resolve_swhids_snapshot_context(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"]) | ||||
head_rev_id = archive_data.snapshot_get_head(snapshot) | head_rev_id = archive_data.snapshot_get_head(snapshot) | ||||
branch_info = random.choice( | |||||
[ | branch_info = None | ||||
{"name": k, "revision": v["target"]} | release_info = None | ||||
vlorentz: `.keys()` is redundant | |||||
for k, v in snapshot["branches"].items() | for branch_name in sorted(snapshot["branches"]): | ||||
if v["target_type"] == "revision" | target_type = snapshot["branches"][branch_name]["target_type"] | ||||
] | target = snapshot["branches"][branch_name]["target"] | ||||
) | if target_type == "revision" and branch_info is None: | ||||
release_info = random.choice( | branch_info = {"name": branch_name, "revision": target} | ||||
[ | elif target_type == "release" and release_info is None: | ||||
{"name": k, "release": v["target"]} | release_info = {"name": branch_name, "release": target} | ||||
for k, v in snapshot["branches"].items() | if branch_info and release_info: | ||||
if v["target_type"] == "release" | break | ||||
] | |||||
) | |||||
release_info["name"] = archive_data.release_get(release_info["release"])["name"] | release_info["name"] = archive_data.release_get(release_info["release"])["name"] | ||||
directory = archive_data.revision_get(branch_info["revision"])["directory"] | directory = archive_data.revision_get(branch_info["revision"])["directory"] | ||||
directory_content = archive_data.directory_ls(directory) | directory_content = archive_data.directory_ls(directory) | ||||
directory_subdirs = [e for e in directory_content if e["type"] == "dir"] | directory_subdirs = [e for e in directory_content if e["type"] == "dir"] | ||||
directory_subdir = None | directory_subdir = None | ||||
if directory_subdirs: | if directory_subdirs: | ||||
directory_subdir = random.choice(directory_subdirs) | directory_subdir = random.choice(directory_subdirs) | ||||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |
.keys() is redundant