Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_origin.py
Show First 20 Lines • Show All 637 Lines • ▼ Show 20 Lines | for browse_context in ("content", "directory"): | ||||
) | ) | ||||
resp = check_html_get_response( | resp = check_html_get_response( | ||||
client, url, status_code=200, template_used=f"browse/{browse_context}.html" | client, url, status_code=200, template_used=f"browse/{browse_context}.html" | ||||
) | ) | ||||
assert re.search("snapshot.*is empty", resp.content.decode("utf-8")) | assert re.search("snapshot.*is empty", resp.content.decode("utf-8")) | ||||
assert mock_get_origin_visit_snapshot.called | assert mock_get_origin_visit_snapshot.called | ||||
assert mock_snapshot_archive.lookup_origin.called | assert mock_snapshot_archive.lookup_origin.called | ||||
assert mock_snapshot_archive.lookup_snapshot_sizes.called | |||||
anlambert: lookup_snapshot_sizes is called once and result is fetched from cache next times so that… | |||||
@given(origin()) | @given(origin()) | ||||
def test_browse_origin_content_not_found(client, origin): | def test_browse_origin_content_not_found(client, origin): | ||||
url = reverse( | url = reverse( | ||||
"browse-origin-content", | "browse-origin-content", | ||||
query_params={"origin_url": origin["url"], "path": "/invalid/file/path"}, | query_params={"origin_url": origin["url"], "path": "/invalid/file/path"}, | ||||
) | ) | ||||
Show All 36 Lines | def test_origin_empty_snapshot(client, mocker, origin): | ||||
resp = check_html_get_response( | resp = check_html_get_response( | ||||
client, url, status_code=200, template_used="browse/directory.html" | client, url, status_code=200, template_used="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_archive.lookup_snapshot_sizes.called | |||||
Done Inline Actionssame here anlambert: same here | |||||
@given(new_origin()) | @given(new_origin()) | ||||
def test_origin_empty_snapshot_null_revision(client, archive_data, new_origin): | def test_origin_empty_snapshot_null_revision(client, archive_data, new_origin): | ||||
snapshot = Snapshot( | snapshot = Snapshot( | ||||
branches={ | branches={ | ||||
b"HEAD": SnapshotBranch( | b"HEAD": SnapshotBranch( | ||||
target="refs/head/master".encode(), target_type=TargetType.ALIAS, | target="refs/head/master".encode(), target_type=TargetType.ALIAS, | ||||
▲ Show 20 Lines • Show All 594 Lines • Show Last 20 Lines |
lookup_snapshot_sizes is called once and result is fetched from cache next times so that assertion do not pass with multiple hypothesis examples