Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/test_snapshot_context.py
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | ): | ||||
release["url"] = reverse( | release["url"] = reverse( | ||||
f"browse-snapshot-{browse_context}", | f"browse-snapshot-{browse_context}", | ||||
url_args=url_args, | url_args=url_args, | ||||
query_params={"release": release["name"], **query_params}, | query_params={"release": release["name"], **query_params}, | ||||
) | ) | ||||
branches_url = reverse("browse-snapshot-branches", url_args=url_args) | branches_url = reverse("browse-snapshot-branches", url_args=url_args) | ||||
releases_url = reverse("browse-snapshot-releases", url_args=url_args) | releases_url = reverse("browse-snapshot-releases", url_args=url_args) | ||||
directory_url = reverse("browse-snapshot-directory", url_args=url_args) | |||||
is_empty = not branches and not releases | is_empty = not branches and not releases | ||||
snapshot_swhid = gen_swhid(ObjectType.SNAPSHOT, snapshot) | snapshot_swhid = gen_swhid(ObjectType.SNAPSHOT, snapshot) | ||||
snapshot_sizes = archive_data.snapshot_count_branches(snapshot) | snapshot_sizes = archive_data.snapshot_count_branches(snapshot) | ||||
expected = SnapshotContext( | expected = SnapshotContext( | ||||
branch="HEAD", | branch="HEAD", | ||||
branch_alias=True, | branch_alias=True, | ||||
branches=branches, | branches=branches, | ||||
Show All 10 Lines | ): | ||||
revision_id=revision_id, | revision_id=revision_id, | ||||
revision_info=_get_revision_info(archive_data, revision_id), | revision_info=_get_revision_info(archive_data, revision_id), | ||||
root_directory=root_directory, | root_directory=root_directory, | ||||
snapshot_id=snapshot, | snapshot_id=snapshot, | ||||
snapshot_sizes=snapshot_sizes, | snapshot_sizes=snapshot_sizes, | ||||
snapshot_swhid=snapshot_swhid, | snapshot_swhid=snapshot_swhid, | ||||
url_args=url_args, | url_args=url_args, | ||||
visit_info=None, | visit_info=None, | ||||
directory_url=directory_url, | |||||
) | ) | ||||
if revision_id: | if revision_id: | ||||
expected["revision_info"]["revision_url"] = gen_revision_url( | expected["revision_info"]["revision_url"] = gen_revision_url( | ||||
revision_id, snapshot_context | revision_id, snapshot_context | ||||
) | ) | ||||
assert snapshot_context == expected | assert snapshot_context == expected | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | ): | ||||
releases_url = reverse("browse-origin-releases", query_params=query_params) | releases_url = reverse("browse-origin-releases", query_params=query_params) | ||||
origin_visits_url = reverse( | origin_visits_url = reverse( | ||||
"browse-origin-visits", query_params={"origin_url": kwargs["origin_url"]} | "browse-origin-visits", query_params={"origin_url": kwargs["origin_url"]} | ||||
) | ) | ||||
is_empty = not branches and not releases | is_empty = not branches and not releases | ||||
snapshot_swhid = gen_swhid(ObjectType.SNAPSHOT, snapshot) | snapshot_swhid = gen_swhid(ObjectType.SNAPSHOT, snapshot) | ||||
snapshot_sizes = archive_data.snapshot_count_branches(snapshot) | snapshot_sizes = archive_data.snapshot_count_branches(snapshot) | ||||
visit_info["url"] = reverse( | visit_info["url"] = directory_url = reverse( | ||||
"browse-origin-directory", query_params=query_params | "browse-origin-directory", query_params=query_params | ||||
) | ) | ||||
anlambert: same here | |||||
visit_info["formatted_date"] = format_utc_iso_date(visit_info["date"]) | visit_info["formatted_date"] = format_utc_iso_date(visit_info["date"]) | ||||
if "path" in kwargs: | if "path" in kwargs: | ||||
query_params["path"] = kwargs["path"] | query_params["path"] = kwargs["path"] | ||||
expected = SnapshotContext( | expected = SnapshotContext( | ||||
branch="HEAD", | branch="HEAD", | ||||
branch_alias=True, | branch_alias=True, | ||||
Show All 11 Lines | ): | ||||
revision_id=revision_id, | revision_id=revision_id, | ||||
revision_info=_get_revision_info(archive_data, revision_id), | revision_info=_get_revision_info(archive_data, revision_id), | ||||
root_directory=root_directory, | root_directory=root_directory, | ||||
snapshot_id=snapshot, | snapshot_id=snapshot, | ||||
snapshot_sizes=snapshot_sizes, | snapshot_sizes=snapshot_sizes, | ||||
snapshot_swhid=snapshot_swhid, | snapshot_swhid=snapshot_swhid, | ||||
url_args={}, | url_args={}, | ||||
visit_info=visit_info, | visit_info=visit_info, | ||||
directory_url=directory_url, | |||||
) | ) | ||||
if revision_id: | if revision_id: | ||||
expected["revision_info"]["revision_url"] = gen_revision_url( | expected["revision_info"]["revision_url"] = gen_revision_url( | ||||
revision_id, snapshot_context | revision_id, snapshot_context | ||||
) | ) | ||||
assert snapshot_context == expected | assert snapshot_context == expected | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |
same here