Example #1
0
 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))
Example #2
0
 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,
     )
Example #3
0
 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",
     )
Example #4
0
 def test_multi_operator_expression(self):
     whitelist = ["MIT"]
     self.assertEqual(
         is_license_ok("(BSD-2-Clause OR MIT OR Apache-2.0)", whitelist),
         True)
Example #5
0
 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))
Example #6
0
 def test_or_license_expression(self):
     whitelist = ["MIT", "Apache-3.0"]
     self.assertTrue(is_license_ok("(MIT OR Apache-2.0)", whitelist))
Example #7
0
 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))
Example #8
0
 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)
Example #9
0
 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)
Example #10
0
 def test_is_license_ok_brackets(self):
     self.assertEqual(is_license_ok("MIT AND Zlib", ["MIT", "Zlib"]), True)
Example #11
0
 def test_is_license_ok_negative(self):
     self.assertEqual(is_license_ok("MIT", [""]), False)
Example #12
0
 def test_is_license_ok_simple(self):
     self.assertEqual(is_license_ok("MIT", ["MIT"]), True)