def test_complex_or_license_expression(self): whitelist = ["MIT", "Apache-3.0"] self.assertTrue( is_license_ok("((MIT and Apache-3.0) OR Apache-2.0)", whitelist)) self.assertTrue( is_license_ok("((License-2 or Apache-3.0) OR Apache-2.0)", whitelist)) self.assertFalse( is_license_ok("((License-2 and Apache-3.0) OR Apache-2.0)", whitelist))
def test_is_license_ok_json(self): self.assertEqual( is_license_ok( { "type": "MIT", "url": "https://github.com/thlorenz/bunyan-format/blob/master/LICENSE", }, [ "{'type': 'MIT', 'url': 'https://github.com/thlorenz/bunyan-format/blob/master/LICENSE'}" ], ), True, )
def test_simple_validation_test(self): whitelist = ["MIT", "Apache-2.0"] self.assertTrue( is_license_ok("MIT", whitelist), "MIT should not be not problematic, it's in a whitelist", )
def test_multi_operator_expression(self): whitelist = ["MIT"] self.assertEqual( is_license_ok("(BSD-2-Clause OR MIT OR Apache-2.0)", whitelist), True)
def test_nested_invalid_expression_inside_complex_or_license_expression( self): whitelist = ["MIT", "Apache-3.0"] self.assertFalse( is_license_ok("((License-2, Apache-3.0) OR Apache-2.0)", whitelist))
def test_or_license_expression(self): whitelist = ["MIT", "Apache-3.0"] self.assertTrue(is_license_ok("(MIT OR Apache-2.0)", whitelist))
def test_and_license_expression(self): whitelist = ["MIT", "Apache-2.0"] self.assertTrue(is_license_ok("(MIT AND Apache-2.0)", whitelist)) self.assertFalse(is_license_ok("(MIT AND Apache-3.0)", whitelist))
def test_unparsable_expression(self): whitelist = ["MIT", "The Apache Software License, Version 2.0"] self.assertEqual( is_license_ok("The Apache Software License, Version 2.0", whitelist), True)
def test_license_in_comma_separated_expression(self): whitelist = ["MIT", "Apache-2.0"] # license.sh doesn't support commas, we support SPDX syntax self.assertEqual(is_license_ok("MIT, Apache 2.0", whitelist), False)
def test_is_license_ok_brackets(self): self.assertEqual(is_license_ok("MIT AND Zlib", ["MIT", "Zlib"]), True)
def test_is_license_ok_negative(self): self.assertEqual(is_license_ok("MIT", [""]), False)
def test_is_license_ok_simple(self): self.assertEqual(is_license_ok("MIT", ["MIT"]), True)