Exemplo n.º 1
0
    def _validate_license(self, license: str) -> str:
        from poetry.core.spdx import license_by_id

        if license:
            license_by_id(license)

        return license
Exemplo n.º 2
0
def test_license_by_id_is_case_insensitive():
    license = license_by_id("mit")

    assert license.id == "MIT"

    license = license_by_id("miT")

    assert license.id == "MIT"
Exemplo n.º 3
0
def test_license_by_id():
    license = license_by_id("MIT")

    assert license.id == "MIT"
    assert license.name == "MIT License"
    assert license.is_osi_approved
    assert not license.is_deprecated

    license = license_by_id("LGPL-3.0-or-later")

    assert license.id == "LGPL-3.0-or-later"
    assert license.name == "GNU Lesser General Public License v3.0 or later"
    assert license.is_osi_approved
    assert not license.is_deprecated
Exemplo n.º 4
0
 def license(self, value):
     if value is None:
         self._license = value
     elif isinstance(value, License):
         self._license = value
     else:
         self._license = license_by_id(value)
Exemplo n.º 5
0
def test_classifier():
    license = license_by_id("lgpl-3.0-or-later")

    assert license.classifier == (
        "License :: "
        "OSI Approved :: "
        "GNU Lesser General Public License v3 or later (LGPLv3+)")
Exemplo n.º 6
0
 def license(self, value):  # type: (Optional[str, License]) -> None
     if value is None:
         self._license = value
     elif isinstance(value, License):
         self._license = value
     else:
         self._license = license_by_id(value)
Exemplo n.º 7
0
def test_license_by_id_custom():
    license = license_by_id("Custom")

    assert license.id == "Custom"
    assert license.name == "Custom"
    assert not license.is_osi_approved
    assert not license.is_deprecated
Exemplo n.º 8
0
def test_custom_license():
    license = license_by_id("Amazon Software License")

    assert "License :: Other/Proprietary License" == license.classifier
Exemplo n.º 9
0
def test_proprietary_license():
    license = license_by_id("Proprietary")

    assert "License :: Other/Proprietary License" == license.classifier
Exemplo n.º 10
0
def test_classifier_no_classifer():
    license = license_by_id("Leptonica")

    assert license.classifier == "License :: Other/Proprietary License"
Exemplo n.º 11
0
def test_classifier_no_classifer_osi_approved():
    license = license_by_id("LiLiQ-R-1.1")

    assert license.classifier == "License :: OSI Approved"
Exemplo n.º 12
0
def test_classifier_name():
    license = license_by_id("lgpl-3.0-or-later")

    assert (license.classifier_name ==
            "GNU Lesser General Public License v3 or later (LGPLv3+)")
Exemplo n.º 13
0
def test_classifier_name_no_classifer_osi_approved():
    license = license_by_id("LiLiQ-R-1.1")

    assert license.classifier_name is None
Exemplo n.º 14
0
def test_license_by_id_invalid():
    with pytest.raises(ValueError):
        license_by_id("")