Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_origin.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import random | import random | ||||
import re | import re | ||||
import string | import string | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | for v in visits: | ||||
query_params={"origin_url": origin["url"], "timestamp": vdate}, | query_params={"origin_url": origin["url"], "timestamp": vdate}, | ||||
) | ) | ||||
assert_contains(resp, browse_dir_url) | assert_contains(resp, browse_dir_url) | ||||
_check_origin_link(resp, origin["url"]) | _check_origin_link(resp, origin["url"]) | ||||
@given(origin_with_multiple_visits()) | @given(origin_with_multiple_visits()) | ||||
def test_origin_content_view(client, archive_data, origin): | def test_origin_content_view(client, archive_data, swh_scheduler, origin): | ||||
origin_visits = archive_data.origin_visit_get(origin["url"]) | origin_visits = archive_data.origin_visit_get(origin["url"]) | ||||
def _get_archive_data(visit_idx): | def _get_archive_data(visit_idx): | ||||
snapshot = archive_data.snapshot_get(origin_visits[visit_idx]["snapshot"]) | snapshot = archive_data.snapshot_get(origin_visits[visit_idx]["snapshot"]) | ||||
head_rev_id = archive_data.snapshot_get_head(snapshot) | head_rev_id = archive_data.snapshot_get_head(snapshot) | ||||
head_rev = archive_data.revision_get(head_rev_id) | head_rev = archive_data.revision_get(head_rev_id) | ||||
dir_content = archive_data.directory_ls(head_rev["directory"]) | dir_content = archive_data.directory_ls(head_rev["directory"]) | ||||
dir_files = [e for e in dir_content if e["type"] == "file"] | dir_files = [e for e in dir_content if e["type"] == "file"] | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | _origin_content_view_test_helper( | ||||
tdata["releases"], | tdata["releases"], | ||||
tdata["root_dir_sha1"], | tdata["root_dir_sha1"], | ||||
tdata["content"], | tdata["content"], | ||||
snapshot_id=tdata["visit"]["snapshot"], | snapshot_id=tdata["visit"]["snapshot"], | ||||
) | ) | ||||
@given(origin()) | @given(origin()) | ||||
def test_origin_root_directory_view(client, archive_data, origin): | def test_origin_root_directory_view(client, archive_data, swh_scheduler, origin): | ||||
origin_visits = archive_data.origin_visit_get(origin["url"]) | origin_visits = archive_data.origin_visit_get(origin["url"]) | ||||
visit = origin_visits[-1] | visit = origin_visits[-1] | ||||
snapshot = archive_data.snapshot_get(visit["snapshot"]) | snapshot = archive_data.snapshot_get(visit["snapshot"]) | ||||
snapshot_sizes = archive_data.snapshot_count_branches(snapshot["id"]) | snapshot_sizes = archive_data.snapshot_count_branches(snapshot["id"]) | ||||
head_rev_id = archive_data.snapshot_get_head(snapshot) | head_rev_id = archive_data.snapshot_get_head(snapshot) | ||||
head_rev = archive_data.revision_get(head_rev_id) | head_rev = archive_data.revision_get(head_rev_id) | ||||
root_dir_sha1 = head_rev["directory"] | root_dir_sha1 = head_rev["directory"] | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | _origin_directory_view_test_helper( | ||||
releases, | releases, | ||||
root_dir_sha1, | root_dir_sha1, | ||||
dir_content, | dir_content, | ||||
snapshot_id=visit["snapshot"], | snapshot_id=visit["snapshot"], | ||||
) | ) | ||||
@given(origin()) | @given(origin()) | ||||
def test_origin_sub_directory_view(client, archive_data, origin): | def test_origin_sub_directory_view(client, archive_data, swh_scheduler, origin): | ||||
origin_visits = archive_data.origin_visit_get(origin["url"]) | origin_visits = archive_data.origin_visit_get(origin["url"]) | ||||
visit = origin_visits[-1] | visit = origin_visits[-1] | ||||
snapshot = archive_data.snapshot_get(visit["snapshot"]) | snapshot = archive_data.snapshot_get(visit["snapshot"]) | ||||
snapshot_sizes = archive_data.snapshot_count_branches(snapshot["id"]) | snapshot_sizes = archive_data.snapshot_count_branches(snapshot["id"]) | ||||
head_rev_id = archive_data.snapshot_get_head(snapshot) | head_rev_id = archive_data.snapshot_get_head(snapshot) | ||||
head_rev = archive_data.revision_get(head_rev_id) | head_rev = archive_data.revision_get(head_rev_id) | ||||
root_dir_sha1 = head_rev["directory"] | root_dir_sha1 = head_rev["directory"] | ||||
▲ Show 20 Lines • Show All 1,015 Lines • Show Last 20 Lines |