Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/browse/views/test_content.py
# Copyright (C) 2017-2021 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 pytest | import pytest | ||||
from django.utils.html import escape | from django.utils.html import escape | ||||
from swh.model.swhids import ObjectType | from swh.model.swhids import ObjectType | ||||
from swh.web.browse.snapshot_context import process_snapshot_branches | from swh.web.browse.snapshot_context import process_snapshot_branches | ||||
from swh.web.browse.utils import ( | from swh.web.browse.utils import ( | ||||
▲ Show 20 Lines • Show All 611 Lines • ▼ Show 20 Lines | def _process_content_for_display(archive_data, content): | ||||
content_display = prepare_content_for_display( | content_display = prepare_content_for_display( | ||||
content_data, mime_type, content["path"] | content_data, mime_type, content["path"] | ||||
) | ) | ||||
assert type(content_display["content_data"]) == str | assert type(content_display["content_data"]) == str | ||||
return content_display | return content_display | ||||
def test_content_dispaly_empty_query_string_missing_path(client): | |||||
url = reverse("browse-content", query_params={"origin_url": "http://example.com"},) | |||||
resp = check_html_get_response(client, url, status_code=400,) | |||||
assert re.search( | |||||
"Path must be provided as a query parameter.", resp.content.decode("utf-8"), | |||||
) | |||||
# def test_content_dispaly_empty_query_string_and_snapshot(client): | |||||
# url = reverse( | |||||
# "browse-content", | |||||
# query_params={"path"}, | |||||
# ) | |||||
# resp = check_html_get_response( | |||||
# client, url, status_code=400, | |||||
# ) |