archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7f91c0baa0b8>
@given(origin_with_multiple_visits())
> def test_get_snapshot_context_with_origin(archive_data, origin):
.tox/py3/lib/python3.7/site-packages/swh/web/tests/browse/test_snapshot_context.py:174:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7f91c0baa0b8>
origin = {'archives': ['highlightjs-line-numbers.js.zip', 'highlightjs-line-numbers.js_visit2.zip'], 'id': b'MZ\xc0H_lE[d\xcc\x...s://doi.org/10.5063/schema/codemeta-2.0', 'description': 'Line numbering plugin for Highlight.js'}, 'type': 'git', ...}
@given(origin_with_multiple_visits())
def test_get_snapshot_context_with_origin(archive_data, origin):
origin_visits = get_origin_visits(origin)
timestamp = format_utc_iso_date(origin_visits[0]["date"], "%Y-%m-%dT%H:%M:%SZ")
visit_id = origin_visits[1]["visit"]
for browse_context, kwargs in (
("content", {"origin_url": origin["url"], "path": "/some/path"}),
("directory", {"origin_url": origin["url"]}),
("log", {"origin_url": origin["url"]}),
("directory", {"origin_url": origin["url"], "timestamp": timestamp,},),
("directory", {"origin_url": origin["url"], "visit_id": visit_id,},),
):
visit_id = kwargs["visit_id"] if "visit_id" in kwargs else None
visit_ts = kwargs["timestamp"] if "timestamp" in kwargs else None
visit_info = get_origin_visit(
{"url": kwargs["origin_url"]}, visit_ts=visit_ts, visit_id=visit_id
)
snapshot = visit_info["snapshot"]
snapshot_context = get_snapshot_context(**kwargs, browse_context=browse_context)
query_params = dict(kwargs)
branches, releases, _ = get_snapshot_content(snapshot)
releases = list(reversed(releases))
revision_id = None
root_directory = None
for branch in branches:
if branch["name"] == "HEAD":
revision_id = branch["revision"]
root_directory = branch["directory"]
branch["url"] = reverse(
f"browse-origin-{browse_context}",
query_params={"branch": branch["name"], **query_params},
)
for release in releases:
release["url"] = reverse(
f"browse-origin-{browse_context}",
query_params={"release": release["name"], **query_params},
)
query_params.pop("path", None)
branches_url = reverse("browse-origin-branches", query_params=query_params)
releases_url = reverse("browse-origin-releases", query_params=query_params)
origin_visits_url = reverse(
"browse-origin-visits", query_params={"origin_url": kwargs["origin_url"]}
)
is_empty = not branches and not releases
snapshot_swhid = gen_swhid(ObjectType.SNAPSHOT, snapshot)
snapshot_sizes = archive_data.snapshot_count_branches(snapshot)
visit_info["url"] = reverse(
"browse-origin-directory", query_params=query_params
)
visit_info["formatted_date"] = format_utc_iso_date(visit_info["date"])
if "path" in kwargs:
query_params["path"] = kwargs["path"]
expected = SnapshotContext(
branch="HEAD",
branch_alias=True,
branches=branches,
branches_url=branches_url,
is_empty=is_empty,
origin_info={"url": origin["url"]},
origin_visits_url=origin_visits_url,
release=None,
release_alias=False,
release_id=None,
query_params=query_params,
releases=releases,
releases_url=releases_url,
revision_id=revision_id,
revision_info=_get_revision_info(archive_data, revision_id),
root_directory=root_directory,
snapshot_id=snapshot,
snapshot_sizes=snapshot_sizes,
snapshot_swhid=snapshot_swhid,
url_args={},
visit_info=visit_info,
)
if revision_id:
expected["revision_info"]["revision_url"] = gen_revision_url(
revision_id, snapshot_context
)
> assert snapshot_context == expected
E AssertionError: assert {'branch': 'H...bers.js', ...} == {'branch': 'H...bers.js', ...}
E Omitting 20 identical items, use -vv to show
E Differing items:
E {'origin_info': {'id': b'MZ\xc0H_lE[d\xcc\xe0\x91\xc6\xd8\x04T\xe1\xd7\x1fk', 'url': 'https://github.com/wcoder/highlightjs-line-numbers.js'}} != {'origin_info': {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js'}}
E Full diff:
E {
E 'branch': 'HEAD',
E 'branch_alias': True,...
E
E ...Full output truncated (225 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/web/tests/browse/test_snapshot_context.py:267: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Sep 28 2021, 7:48 PM