# SPDX-License-Identifier: MIT from fastapi import Request 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", "&", "<", ">"]) == \ "FOO OR & OR < OR >" assert licenses_to_html(r, ["spdx:FOO-BAR.OK"]) == ( 'FOO-BAR.OK') assert licenses_to_html(r, ["spdx:< > &"]) == '< > &' assert licenses_to_html(r, ["spdx:(FOO)"]) == \ '(FOO)' assert licenses_to_html(r, ["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"]) == \ 'BLA OR GPL' assert licenses_to_html(r, ["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"]) == ( 'GPL-2.0-or-later WITH ' 'Autoconf-exception-2.0' ) assert licenses_to_html(r, ["spdx:GPL-2.0+"]) == ( 'GPL-2.0+' ) assert licenses_to_html(r, ["spdx:StandardML-NJ"]) == ( 'StandardML-NJ' ) assert licenses_to_html(r, ["spdx:LicenseRef-foobar"]) == 'foobar'