diff --git a/swh/web/tests/api/test_apiresponse.py b/swh/web/tests/api/test_apiresponse.py
--- a/swh/web/tests/api/test_apiresponse.py
+++ b/swh/web/tests/api/test_apiresponse.py
@@ -22,7 +22,7 @@
from swh.web.common.identifiers import gen_swhid
from swh.web.common.utils import reverse
from swh.web.tests.django_asserts import assert_contains
-from swh.web.tests.strategies import content, directory, revision
+from swh.web.tests.strategies import directory, revision
from swh.web.tests.utils import check_http_get_response, check_http_post_response
@@ -153,7 +153,7 @@
assert "Traceback" in resp.data["traceback"]
-@given(content(), directory(), revision())
+@given(directory(), revision())
def test_api_endpoints_have_cors_headers(client, content, directory, revision):
url = reverse("api-1-stat-counters")
diff --git a/swh/web/tests/api/test_utils.py b/swh/web/tests/api/test_utils.py
--- a/swh/web/tests/api/test_utils.py
+++ b/swh/web/tests/api/test_utils.py
@@ -11,14 +11,7 @@
from swh.web.api import utils
from swh.web.common.origin_visits import get_origin_visits
from swh.web.common.utils import resolve_branch_alias, reverse
-from swh.web.tests.strategies import (
- content,
- directory,
- origin,
- release,
- revision,
- snapshot,
-)
+from swh.web.tests.strategies import directory, origin, release, revision, snapshot
url_map = [
{
@@ -227,7 +220,6 @@
assert utils.enrich_content({"id": "123"}) == {"id": "123"}
-@given(content())
def test_enrich_content_with_hashes(api_request_factory, content):
for algo in DEFAULT_ALGORITHMS:
@@ -262,7 +254,6 @@
assert enriched_content == content_data
-@given(content())
def test_enrich_content_with_hashes_and_top_level_url(api_request_factory, content):
for algo in DEFAULT_ALGORITHMS:
diff --git a/swh/web/tests/api/views/test_content.py b/swh/web/tests/api/views/test_content.py
--- a/swh/web/tests/api/views/test_content.py
+++ b/swh/web/tests/api/views/test_content.py
@@ -3,13 +3,11 @@
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
-from hypothesis import given
import pytest
from swh.web.common.utils import reverse
from swh.web.tests.conftest import ctags_json_missing, fossology_missing
from swh.web.tests.data import random_content
-from swh.web.tests.strategies import content, contents_with_ctags
from swh.web.tests.utils import (
check_api_get_responses,
check_api_post_responses,
@@ -17,7 +15,6 @@
)
-@given(content())
def test_api_content_filetype(api_client, indexer_data, content):
indexer_data.content_add_mimetype(content["sha1"])
url = reverse(
@@ -68,7 +65,6 @@
@pytest.mark.skipif(
ctags_json_missing, reason="requires ctags with json output support"
)
-@given(contents_with_ctags())
def test_api_content_symbol(api_client, indexer_data, contents_with_ctags):
expected_data = {}
for content_sha1 in contents_with_ctags["sha1s"]:
@@ -136,7 +132,6 @@
@pytest.mark.skipif(
ctags_json_missing, reason="requires ctags with json output support"
)
-@given(content())
def test_api_content_ctags(api_client, indexer_data, content):
indexer_data.content_add_ctags(content["sha1"])
url = reverse(
@@ -155,7 +150,6 @@
@pytest.mark.skipif(fossology_missing, reason="requires fossology-nomossa installed")
-@given(content())
def test_api_content_license(api_client, indexer_data, content):
indexer_data.content_add_license(content["sha1"])
url = reverse(
@@ -191,7 +185,6 @@
}
-@given(content())
def test_api_content_metadata(api_client, archive_data, content):
url = reverse("api-1-content", {"q": "sha1:%s" % content["sha1"]})
rv = check_api_get_responses(api_client, url, status_code=200)
@@ -236,7 +229,6 @@
}
-@given(content())
def test_api_content_raw_text(api_client, archive_data, content):
url = reverse("api-1-content-raw", url_args={"q": "sha1:%s" % content["sha1"]})
@@ -250,7 +242,6 @@
assert rv.content == expected_data["data"]
-@given(content())
def test_api_content_raw_text_with_filename(api_client, archive_data, content):
url = reverse(
"api-1-content-raw",
@@ -264,7 +255,6 @@
assert rv.content == expected_data["data"]
-@given(content())
def test_api_check_content_known(api_client, content):
url = reverse("api-1-content-known", url_args={"q": content["sha1"]})
rv = check_api_get_responses(api_client, url, status_code=200)
@@ -274,7 +264,6 @@
}
-@given(content())
def test_api_check_content_known_post(api_client, content):
url = reverse("api-1-content-known")
rv = check_api_post_responses(
@@ -298,7 +287,6 @@
}
-@given(content())
def test_api_content_uppercase(api_client, content):
url = reverse(
"api-1-content-uppercase-checksum", url_args={"q": content["sha1"].upper()}
diff --git a/swh/web/tests/api/views/test_identifiers.py b/swh/web/tests/api/views/test_identifiers.py
--- a/swh/web/tests/api/views/test_identifiers.py
+++ b/swh/web/tests/api/views/test_identifiers.py
@@ -10,7 +10,6 @@
from swh.web.common.utils import reverse
from swh.web.tests.data import random_sha1
from swh.web.tests.strategies import (
- content,
directory,
origin,
release,
@@ -25,9 +24,9 @@
from swh.web.tests.utils import check_api_get_responses, check_api_post_responses
-@given(origin(), content(), directory(), release(), revision(), snapshot())
+@given(origin(), directory(), release(), revision(), snapshot())
def test_swhid_resolve_success(
- api_client, client, origin, content, directory, release, revision, snapshot
+ api_client, client, content, origin, directory, release, revision, snapshot
):
for obj_type, obj_id in (
@@ -116,7 +115,7 @@
check_api_get_responses(api_client, url, status_code=400)
-@given(content(), directory(), release(), revision(), snapshot())
+@given(directory(), release(), revision(), snapshot())
def test_api_known_swhid_all_present(
api_client, content, directory, release, revision, snapshot
):
@@ -135,7 +134,7 @@
assert resp.data == {swhid: {"known": True} for swhid in input_swhids}
-@given(content(), directory())
+@given(directory())
def test_api_known_swhid_some_present(api_client, content, directory):
content_ = gen_swhid(ObjectType.CONTENT, content["sha1_git"])
directory_ = gen_swhid(ObjectType.DIRECTORY, directory)
diff --git a/swh/web/tests/api/views/test_release.py b/swh/web/tests/api/views/test_release.py
--- a/swh/web/tests/api/views/test_release.py
+++ b/swh/web/tests/api/views/test_release.py
@@ -17,7 +17,7 @@
)
from swh.web.common.utils import reverse
from swh.web.tests.data import random_sha1
-from swh.web.tests.strategies import content, directory, release
+from swh.web.tests.strategies import directory, release
from swh.web.tests.utils import check_api_get_responses, check_http_get_response
@@ -39,7 +39,7 @@
assert rv.data == expected_release
-@given(content(), directory(), release())
+@given(directory(), release())
def test_api_release_target_type_not_a_revision(
api_client, archive_data, content, directory, release
):
diff --git a/swh/web/tests/api/views/test_revision.py b/swh/web/tests/api/views/test_revision.py
--- a/swh/web/tests/api/views/test_revision.py
+++ b/swh/web/tests/api/views/test_revision.py
@@ -17,7 +17,7 @@
from swh.web.api.utils import enrich_content, enrich_directory_entry, enrich_revision
from swh.web.common.utils import reverse
from swh.web.tests.data import random_sha1
-from swh.web.tests.strategies import content, new_person, new_swh_date, revision
+from swh.web.tests.strategies import new_person, new_swh_date, revision
from swh.web.tests.utils import check_api_get_responses, check_http_get_response
@@ -132,7 +132,7 @@
}
-@given(content(), new_person(), new_swh_date())
+@given(new_person(), new_swh_date())
def test_api_revision_directory_ok_returns_content(
api_client, archive_data, content, person, date
):
diff --git a/swh/web/tests/browse/views/test_content.py b/swh/web/tests/browse/views/test_content.py
--- a/swh/web/tests/browse/views/test_content.py
+++ b/swh/web/tests/browse/views/test_content.py
@@ -21,14 +21,6 @@
from swh.web.common.utils import gen_path_info, reverse
from swh.web.tests.django_asserts import assert_contains, assert_not_contains
from swh.web.tests.strategies import (
- content,
- content_application_no_highlight,
- content_image_type,
- content_text,
- content_text_no_highlight,
- content_text_non_utf8,
- content_unsupported_image_type_rendering,
- content_utf8_detected_as_binary,
invalid_sha1,
origin_with_multiple_visits,
unknown_content,
@@ -36,23 +28,24 @@
from swh.web.tests.utils import check_html_get_response, check_http_get_response
-@given(content_text())
-def test_content_view_text(client, archive_data, content):
- sha1_git = content["sha1_git"]
+def test_content_view_text(client, archive_data, content_text):
+ sha1_git = content_text["sha1_git"]
url = reverse(
"browse-content",
- url_args={"query_string": content["sha1"]},
- query_params={"path": content["path"]},
+ url_args={"query_string": content_text["sha1"]},
+ query_params={"path": content_text["path"]},
)
- url_raw = reverse("browse-content-raw", url_args={"query_string": content["sha1"]})
+ url_raw = reverse(
+ "browse-content-raw", url_args={"query_string": content_text["sha1"]}
+ )
resp = check_html_get_response(
client, url, status_code=200, template_used="browse/content.html"
)
- content_display = _process_content_for_display(archive_data, content)
+ content_display = _process_content_for_display(archive_data, content_text)
mimetype = content_display["mimetype"]
if mimetype.startswith("text/"):
@@ -67,9 +60,10 @@
assert_not_contains(resp, "swh-metadata-popover")
-@given(content_application_no_highlight(), content_text_no_highlight())
-def test_content_view_no_highlight(client, archive_data, content_app, content_text):
- for content_ in (content_app, content_text):
+def test_content_view_no_highlight(
+ client, archive_data, content_application_no_highlight, content_text_no_highlight
+):
+ for content_ in (content_application_no_highlight, content_text_no_highlight):
content = content_
sha1_git = content["sha1_git"]
@@ -96,17 +90,18 @@
assert_contains(resp, swh_cnt_id_url)
-@given(content_text_non_utf8())
-def test_content_view_no_utf8_text(client, archive_data, content):
- sha1_git = content["sha1_git"]
+def test_content_view_no_utf8_text(client, archive_data, content_text_non_utf8):
+ sha1_git = content_text_non_utf8["sha1_git"]
- url = reverse("browse-content", url_args={"query_string": content["sha1"]})
+ url = reverse(
+ "browse-content", url_args={"query_string": content_text_non_utf8["sha1"]}
+ )
resp = check_html_get_response(
client, url, status_code=200, template_used="browse/content.html"
)
- content_display = _process_content_for_display(archive_data, content)
+ content_display = _process_content_for_display(archive_data, content_text_non_utf8)
swh_cnt_id = gen_swhid(ObjectType.CONTENT, sha1_git)
swh_cnt_id_url = reverse("browse-swhid", url_args={"swhid": swh_cnt_id})
@@ -114,33 +109,40 @@
assert_contains(resp, escape(content_display["content_data"]))
-@given(content_image_type())
-def test_content_view_image(client, archive_data, content):
- url = reverse("browse-content", url_args={"query_string": content["sha1"]})
+def test_content_view_image(client, archive_data, content_image_type):
+ url = reverse(
+ "browse-content", url_args={"query_string": content_image_type["sha1"]}
+ )
- url_raw = reverse("browse-content-raw", url_args={"query_string": content["sha1"]})
+ url_raw = reverse(
+ "browse-content-raw", url_args={"query_string": content_image_type["sha1"]}
+ )
resp = check_html_get_response(
client, url, status_code=200, template_used="browse/content.html"
)
- content_display = _process_content_for_display(archive_data, content)
+ content_display = _process_content_for_display(archive_data, content_image_type)
mimetype = content_display["mimetype"]
content_data = content_display["content_data"]
assert_contains(resp, '' % (mimetype, content_data))
assert_contains(resp, url_raw)
-@given(content_unsupported_image_type_rendering())
-def test_content_view_image_no_rendering(client, archive_data, content):
- url = reverse("browse-content", url_args={"query_string": content["sha1"]})
+def test_content_view_image_no_rendering(
+ client, archive_data, content_unsupported_image_type_rendering
+):
+ url = reverse(
+ "browse-content",
+ url_args={"query_string": content_unsupported_image_type_rendering["sha1"]},
+ )
resp = check_html_get_response(
client, url, status_code=200, template_used="browse/content.html"
)
- mimetype = content["mimetype"]
- encoding = content["encoding"]
+ mimetype = content_unsupported_image_type_rendering["mimetype"]
+ encoding = content_unsupported_image_type_rendering["encoding"]
assert_contains(
resp,
(
@@ -150,13 +152,12 @@
)
-@given(content_text())
-def test_content_view_text_with_path(client, archive_data, content):
- path = content["path"]
+def test_content_view_text_with_path(client, archive_data, content_text):
+ path = content_text["path"]
url = reverse(
"browse-content",
- url_args={"query_string": content["sha1"]},
+ url_args={"query_string": content_text["sha1"]},
query_params={"path": path},
)
@@ -166,11 +167,11 @@
assert_contains(resp, '