Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_directory.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 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 textwrap | |||||
from hypothesis import given | from hypothesis import given | ||||
from swh.web.common.identifiers import get_swh_persistent_id | from swh.web.common.identifiers import get_swh_persistent_id | ||||
from swh.web.common.utils import gen_path_info, reverse | from swh.web.common.utils import gen_path_info, reverse | ||||
from swh.web.tests.django_asserts import assert_contains, assert_template_used | from swh.web.tests.django_asserts import assert_contains, assert_template_used | ||||
from swh.web.tests.strategies import ( | from swh.web.tests.strategies import ( | ||||
directory, | directory, | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | for p in path_info: | ||||
assert_contains(resp, '<a href="%s">%s</a>' % (dir_url, p["name"])) | assert_contains(resp, '<a href="%s">%s</a>' % (dir_url, p["name"])) | ||||
assert_contains(resp, "vault-cook-directory") | assert_contains(resp, "vault-cook-directory") | ||||
swh_dir_id = get_swh_persistent_id("directory", directory_entries[0]["dir_id"]) | swh_dir_id = get_swh_persistent_id("directory", directory_entries[0]["dir_id"]) | ||||
swh_dir_id_url = reverse("browse-swh-id", url_args={"swh_id": swh_dir_id}) | swh_dir_id_url = reverse("browse-swh-id", url_args={"swh_id": swh_dir_id}) | ||||
assert_contains(resp, swh_dir_id) | assert_contains(resp, swh_dir_id) | ||||
assert_contains(resp, swh_dir_id_url) | assert_contains(resp, swh_dir_id_url) | ||||
assert_contains( | |||||
resp, | |||||
textwrap.indent( | |||||
( | |||||
f"Browse archived directory\n" | |||||
f'<a href="{swh_dir_id_url}">\n' | |||||
f" {swh_dir_id}\n" | |||||
f"</a>" | |||||
), | |||||
" " * 4, | |||||
), | |||||
) |