Repository Public Research preview
1from htr.licenses.policy import LicenseRecord, is_release_eligible, is_training_eligible, normalize_license, permitted_ops234def test_normalize():5 assert normalize_license("CC BY") == "CC-BY"6 assert normalize_license("CC BY-NC-ND") == "CC-BY-NC-ND"7 assert normalize_license(uri="https://creativecommons.org/licenses/by-sa/4.0/") == "CC-BY-SA"8 assert normalize_license("CC BY", uri="http://creativecommons.org/licenses/by-nc/4.0/") == "CC-BY-NC" # URI wins9 assert normalize_license(uri="http://arxiv.org/licenses/nonexclusive-distrib/1.0/") == "ARXIV-NONEXCLUSIVE"10 assert normalize_license("TDM") == "TDM"11 assert normalize_license(None) == "UNKNOWN"121314def test_policy_tiers():15 assert is_training_eligible("CC-BY") and is_release_eligible("CC-BY")16 assert is_training_eligible("CC-BY-NC") and not is_release_eligible("CC-BY-NC")17 assert not is_training_eligible("CC-BY-ND") and "train" not in permitted_ops("CC-BY-ND")18 assert not is_training_eligible("ARXIV-NONEXCLUSIVE")19 r = LicenseRecord(code="CC0", evidence="test")20 assert r.tier == "A" and "release_derivative_text" in r.permitted21