client = <django.test.client.Client object at 0x7f9253cf47b8>
archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7f92535f60f0>
swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7f92535f6828>
origin_with_multiple_visits = {'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', ...}
def test_origin_content_view(
client, archive_data, swh_scheduler, origin_with_multiple_visits
):
origin_visits = archive_data.origin_visit_get(origin_with_multiple_visits["url"])
def _get_archive_data(visit_idx):
snapshot = archive_data.snapshot_get(origin_visits[visit_idx]["snapshot"])
head_rev_id = archive_data.snapshot_get_head(snapshot)
head_rev = archive_data.revision_get(head_rev_id)
dir_content = archive_data.directory_ls(head_rev["directory"])
dir_files = [e for e in dir_content if e["type"] == "file"]
dir_file = random.choice(dir_files)
branches, releases, _ = process_snapshot_branches(snapshot)
return {
"branches": branches,
"releases": releases,
"root_dir_sha1": head_rev["directory"],
"content": get_content(dir_file["checksums"]["sha1"]),
"visit": origin_visits[visit_idx],
"snapshot_sizes": archive_data.snapshot_count_branches(snapshot["id"]),
}
tdata = _get_archive_data(-1)
_origin_content_view_test_helper(
client,
archive_data,
origin_with_multiple_visits,
origin_visits[-1],
tdata["snapshot_sizes"],
tdata["branches"],
tdata["releases"],
tdata["root_dir_sha1"],
> tdata["content"],
)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/browse/views/test_origin.py:93:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/browse/views/test_origin.py:881: in _origin_content_view_test_helper
client, url, status_code=200, template_used="browse/content.html"
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:207: in check_html_get_response
client, url, status_code, content_type="text/html"
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:68: in check_http_get_response
content_type=content_type,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = <HttpResponsePermanentRedirect status_code=301, "text/html; charset=utf-8", url="/browse/content/?origin_url=https://github.com/wcoder/highlightjs-line-numbers.js&path=LICENSE&visit_id=2">
status_code = 200, content_type = 'text/html'
def _assert_http_response(
response: HttpResponse, status_code: int, content_type: str
) -> HttpResponse:
if isinstance(response, Response):
drf_response = cast(Response, response)
error_context = (
drf_response.data.pop("traceback")
if isinstance(drf_response.data, dict) and "traceback" in drf_response.data
else drf_response.data
)
elif isinstance(response, StreamingHttpResponse):
error_context = getattr(response, "traceback", response.streaming_content)
else:
error_context = getattr(response, "traceback", response.content)
> assert response.status_code == status_code, error_context
E AssertionError: b''
E assert 301 == 200
E +301
E -200
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:34: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Nov 5 2021, 1:47 PM