diff --git a/app/web.py b/app/web.py
index bb30e1c..78d91f5 100644
--- a/app/web.py
+++ b/app/web.py
@@ -152,8 +152,7 @@ def _license_to_html(license: str) -> str:
return str(markupsafe.escape(license))
-@context_function("licenses_to_html")
-def licenses_to_html(request: Request, licenses: list[str]) -> str:
+def _licenses_to_html(licenses: list[str]) -> str:
done = []
for license in licenses:
needs_quote = (" " in license.strip()) and len(licenses) > 1
@@ -166,6 +165,11 @@ def licenses_to_html(request: Request, licenses: list[str]) -> str:
return " OR ".join(done)
+@context_function("licenses_to_html")
+def licenses_to_html(request: Request, licenses: list[str]) -> str:
+ return _licenses_to_html(licenses)
+
+
@template_filter("rdepends_type")
def rdepends_type(types: set[DepType]) -> list[str]:
if list(types) == [DepType.NORMAL]:
diff --git a/tests/test_web.py b/tests/test_web.py
index 0e82961..47452ca 100644
--- a/tests/test_web.py
+++ b/tests/test_web.py
@@ -1,40 +1,37 @@
# SPDX-License-Identifier: MIT
-from fastapi import Request
-
-from app.web import licenses_to_html
+from app.web import _licenses_to_html
def test_licenses_to_html() -> None:
- r = Request({"type": "http"})
- assert licenses_to_html(r, []) == ""
- assert licenses_to_html(r, ["FOO"]) == "FOO"
- assert licenses_to_html(r, ["FOO", "BAR"]) == "FOO OR BAR"
- assert licenses_to_html(r, ["FOO", "&", "<", ">"]) == \
+ assert _licenses_to_html([]) == ""
+ assert _licenses_to_html(["FOO"]) == "FOO"
+ assert _licenses_to_html(["FOO", "BAR"]) == "FOO OR BAR"
+ assert _licenses_to_html(["FOO", "&", "<", ">"]) == \
"FOO OR & OR < OR >"
- assert licenses_to_html(r, ["spdx:FOO-BAR.OK"]) == (
+ assert _licenses_to_html(["spdx:FOO-BAR.OK"]) == (
'FOO-BAR.OK')
- assert licenses_to_html(r, ["spdx:< > &"]) == '< > &'
- assert licenses_to_html(r, ["spdx:(FOO)"]) == \
+ assert _licenses_to_html(["spdx:< > &"]) == '< > &'
+ assert _licenses_to_html(["spdx:(FOO)"]) == \
'(FOO)'
- assert licenses_to_html(r, ["spdx:FOO", "spdx:BAR"]) == (
+ assert _licenses_to_html(["spdx:FOO", "spdx:BAR"]) == (
'FOO OR '
'BAR')
- assert licenses_to_html(r, ["custom:BLA", "GPL"]) == "custom:BLA OR GPL"
- assert licenses_to_html(r, ["spdx:BLA", "GPL"]) == \
+ assert _licenses_to_html(["custom:BLA", "GPL"]) == "custom:BLA OR GPL"
+ assert _licenses_to_html(["spdx:BLA", "GPL"]) == \
'BLA OR GPL'
- assert licenses_to_html(r, ["spdx:MIT OR BSD-3-Clause", "GPL"]) == (
+ assert _licenses_to_html(["spdx:MIT OR BSD-3-Clause", "GPL"]) == (
'(MIT OR '
'BSD-3-Clause) OR GPL')
- assert licenses_to_html(r, ["&<>"]) == "&<>"
- assert licenses_to_html(r, ["spdx:GPL-2.0-or-later WITH Autoconf-exception-2.0"]) == (
+ assert _licenses_to_html(["&<>"]) == "&<>"
+ assert _licenses_to_html(["spdx:GPL-2.0-or-later WITH Autoconf-exception-2.0"]) == (
'GPL-2.0-or-later WITH '
'Autoconf-exception-2.0'
)
- assert licenses_to_html(r, ["spdx:GPL-2.0+"]) == (
+ assert _licenses_to_html(["spdx:GPL-2.0+"]) == (
'GPL-2.0+'
)
- assert licenses_to_html(r, ["spdx:StandardML-NJ"]) == (
+ assert _licenses_to_html(["spdx:StandardML-NJ"]) == (
'StandardML-NJ'
)
- assert licenses_to_html(r, ["spdx:LicenseRef-foobar"]) == 'foobar'
+ assert _licenses_to_html(["spdx:LicenseRef-foobar"]) == 'foobar'