Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_origin.py
Show First 20 Lines • Show All 588 Lines • ▼ Show 20 Lines | mock_get_origin_visit_snapshot = mocker.patch( | ||||
"swh.web.browse.snapshot_context.get_origin_visit_snapshot" | "swh.web.browse.snapshot_context.get_origin_visit_snapshot" | ||||
) | ) | ||||
mock_get_origin_visit_snapshot.return_value = ([], []) | mock_get_origin_visit_snapshot.return_value = ([], []) | ||||
mock_service.lookup_snapshot_sizes.return_value = { | mock_service.lookup_snapshot_sizes.return_value = { | ||||
"revision": 0, | "revision": 0, | ||||
"release": 0, | "release": 0, | ||||
} | } | ||||
mock_service.lookup_origin.return_value = origin | mock_service.lookup_origin.return_value = origin | ||||
url = reverse("browse-origin-directory", url_args={"origin_url": "bar"}) | url = reverse("browse-origin-directory", url_args={"origin_url": origin["url"]}) | ||||
resp = client.get(url) | resp = client.get(url) | ||||
assert resp.status_code == 200 | assert resp.status_code == 200 | ||||
assert_template_used(resp, "browse/directory.html") | assert_template_used(resp, "browse/directory.html") | ||||
resp_content = resp.content.decode("utf-8") | resp_content = resp.content.decode("utf-8") | ||||
assert re.search("snapshot.*is empty", resp_content) | assert re.search("snapshot.*is empty", resp_content) | ||||
assert not re.search("swh-tr-link", resp_content) | assert not re.search("swh-tr-link", resp_content) | ||||
assert mock_get_origin_visit_snapshot.called | assert mock_get_origin_visit_snapshot.called | ||||
assert mock_service.lookup_snapshot_sizes.called | assert mock_service.lookup_snapshot_sizes.called | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | ): | ||||
path = content_path.replace(filename, "")[:-1] | path = content_path.replace(filename, "")[:-1] | ||||
path_info = gen_path_info(path) | path_info = gen_path_info(path) | ||||
del url_args["path"] | del url_args["path"] | ||||
if timestamp: | if timestamp: | ||||
url_args["timestamp"] = format_utc_iso_date( | url_args["timestamp"] = format_utc_iso_date( | ||||
parse_timestamp(timestamp).isoformat(), "%Y-%m-%dT%H:%M:%S" | parse_timestamp(timestamp).isoformat(), "%Y-%m-%dT%H:%M:%SZ" | ||||
) | ) | ||||
root_dir_url = reverse( | root_dir_url = reverse( | ||||
"browse-origin-directory", url_args=url_args, query_params=query_params | "browse-origin-directory", url_args=url_args, query_params=query_params | ||||
) | ) | ||||
assert_contains(resp, '<li class="swh-path">', count=len(path_info) + 1) | assert_contains(resp, '<li class="swh-path">', count=len(path_info) + 1) | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | ): | ||||
assert resp.status_code == 200 | assert resp.status_code == 200 | ||||
assert_template_used(resp, "browse/directory.html") | assert_template_used(resp, "browse/directory.html") | ||||
assert_contains(resp, '<td class="swh-directory">', count=len(dirs)) | assert_contains(resp, '<td class="swh-directory">', count=len(dirs)) | ||||
assert_contains(resp, '<td class="swh-content">', count=len(files)) | assert_contains(resp, '<td class="swh-content">', count=len(files)) | ||||
if timestamp: | if timestamp: | ||||
url_args["timestamp"] = format_utc_iso_date( | url_args["timestamp"] = format_utc_iso_date( | ||||
parse_timestamp(timestamp).isoformat(), "%Y-%m-%dT%H:%M:%S" | parse_timestamp(timestamp).isoformat(), "%Y-%m-%dT%H:%M:%SZ" | ||||
) | ) | ||||
for d in dirs: | for d in dirs: | ||||
if d["type"] == "rev": | if d["type"] == "rev": | ||||
dir_url = reverse("browse-revision", url_args={"sha1_git": d["target"]}) | dir_url = reverse("browse-revision", url_args={"sha1_git": d["target"]}) | ||||
else: | else: | ||||
dir_path = d["name"] | dir_path = d["name"] | ||||
if path: | if path: | ||||
▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines |