Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/misc/test_iframe.py
# Copyright (C) 2021 The Software Heritage developers | # Copyright (C) 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 | ||||
from hypothesis import given | from hypothesis import given | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.swhids import CoreSWHID, ObjectType | from swh.model.swhids import CoreSWHID, ObjectType | ||||
from swh.web.common.utils import reverse | from swh.web.common.utils import reverse | ||||
from swh.web.tests.strategies import directory_swhid, revision_swhid, unknown_directory | from swh.web.tests.strategies import revision_swhid, unknown_directory | ||||
from swh.web.tests.utils import check_html_get_response | from swh.web.tests.utils import check_html_get_response | ||||
def test_content_swhid_iframe(client, content_swhid): | def test_content_swhid_iframe(client, content_swhid): | ||||
url = reverse("swhid-iframe", url_args={"swhid": str(content_swhid)}) | url = reverse("swhid-iframe", url_args={"swhid": str(content_swhid)}) | ||||
check_html_get_response( | check_html_get_response( | ||||
client, url, status_code=200, template_used="misc/iframe.html" | client, url, status_code=200, template_used="misc/iframe.html" | ||||
) | ) | ||||
def test_content_core_swhid_iframe(client, content_swhid): | def test_content_core_swhid_iframe(client, content_swhid): | ||||
content_core_swhid = CoreSWHID( | content_core_swhid = CoreSWHID( | ||||
object_type=content_swhid.object_type, object_id=content_swhid.object_id | object_type=content_swhid.object_type, object_id=content_swhid.object_id | ||||
) | ) | ||||
url = reverse("swhid-iframe", url_args={"swhid": str(content_core_swhid)}) | url = reverse("swhid-iframe", url_args={"swhid": str(content_core_swhid)}) | ||||
check_html_get_response( | check_html_get_response( | ||||
client, url, status_code=200, template_used="misc/iframe.html" | client, url, status_code=200, template_used="misc/iframe.html" | ||||
) | ) | ||||
@given(directory_swhid()) | |||||
def test_directory_swhid_iframe(client, directory_swhid): | def test_directory_swhid_iframe(client, directory_swhid): | ||||
url = reverse("swhid-iframe", url_args={"swhid": str(directory_swhid)}) | url = reverse("swhid-iframe", url_args={"swhid": str(directory_swhid)}) | ||||
check_html_get_response( | check_html_get_response( | ||||
client, url, status_code=200, template_used="misc/iframe.html" | client, url, status_code=200, template_used="misc/iframe.html" | ||||
) | ) | ||||
@given(directory_swhid()) | |||||
def test_directory_core_swhid_iframe(client, directory_swhid): | def test_directory_core_swhid_iframe(client, directory_swhid): | ||||
directory_core_swhid = CoreSWHID( | directory_core_swhid = CoreSWHID( | ||||
object_type=directory_swhid.object_type, object_id=directory_swhid.object_id | object_type=directory_swhid.object_type, object_id=directory_swhid.object_id | ||||
) | ) | ||||
url = reverse("swhid-iframe", url_args={"swhid": str(directory_core_swhid)}) | url = reverse("swhid-iframe", url_args={"swhid": str(directory_core_swhid)}) | ||||
check_html_get_response( | check_html_get_response( | ||||
client, url, status_code=200, template_used="misc/iframe.html" | client, url, status_code=200, template_used="misc/iframe.html" | ||||
) | ) | ||||
Show All 27 Lines |