# 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"]) == "BAR OR FOO" assert licenses_to_html(r, ["FOO", "&", "<", ">"]) == \ "& OR < OR > OR FOO" 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"]) == ( 'BAR OR ' 'FOO') assert licenses_to_html(r, ["custom:BLA", "GPL"]) == "GPL OR custom:BLA" assert licenses_to_html(r, ["spdx:BLA", "GPL"]) == \ 'GPL OR BLA' assert licenses_to_html(r, ["spdx:MIT OR BSD-3-Clause", "GPL"]) == ( 'GPL OR (MIT OR ' 'BSD-3-Clause)') 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'