summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/tests
diff options
context:
space:
mode:
authorChristopher Larson <kergoth@gmail.com>2011-12-04 20:03:51 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-12-08 15:24:29 +0000
commit9fb67f895c2616c4dfb8521d3dd5c36758570d83 (patch)
treed89b3e073b0eb281a31ebc9e08c12293413f52dc /meta/lib/oe/tests
parenta57de1ac9de96eef13f1fd6d37f3f73808d075ac (diff)
downloadpoky-9fb67f895c2616c4dfb8521d3dd5c36758570d83.tar.gz
oe.license: add license flattening code
This flattens a license tree by selecting one side of each OR operation (chosen via the user supplied function). (From OE-Core rev: 6984961314c8ba2aceab9acabb658f96ed249fef) Signed-off-by: Christopher Larson <kergoth@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/tests')
-rw-r--r--meta/lib/oe/tests/test_license.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/meta/lib/oe/tests/test_license.py b/meta/lib/oe/tests/test_license.py
index cb949fc76f..c388886184 100644
--- a/meta/lib/oe/tests/test_license.py
+++ b/meta/lib/oe/tests/test_license.py
@@ -36,3 +36,33 @@ class TestSingleLicense(unittest.TestCase):
36 with self.assertRaises(oe.license.InvalidLicense) as cm: 36 with self.assertRaises(oe.license.InvalidLicense) as cm:
37 self.parse(license) 37 self.parse(license)
38 self.assertEqual(cm.exception.license, license) 38 self.assertEqual(cm.exception.license, license)
39
40class TestSimpleCombinations(unittest.TestCase):
41 tests = {
42 "FOO&BAR": ["FOO", "BAR"],
43 "BAZ & MOO": ["BAZ", "MOO"],
44 "ALPHA|BETA": ["ALPHA"],
45 "BAZ&MOO|FOO": ["FOO"],
46 "FOO&BAR|BAZ": ["FOO", "BAR"],
47 }
48 preferred = ["ALPHA", "FOO", "BAR"]
49
50 def test_tests(self):
51 def choose(a, b):
52 if all(lic in self.preferred for lic in b):
53 return b
54 else:
55 return a
56
57 for license, expected in self.tests.items():
58 licenses = oe.license.flattened_licenses(license, choose)
59 self.assertListEqual(licenses, expected)
60
61class TestComplexCombinations(TestSimpleCombinations):
62 tests = {
63 "FOO & (BAR | BAZ)&MOO": ["FOO", "BAR", "MOO"],
64 "(ALPHA|(BETA&THETA)|OMEGA)&DELTA": ["OMEGA", "DELTA"],
65 "((ALPHA|BETA)&FOO)|BAZ": ["BETA", "FOO"],
66 "(GPL-2.0|Proprietary)&BSD-4-clause&MIT": ["GPL-2.0", "BSD-4-clause", "MIT"],
67 }
68 preferred = ["BAR", "OMEGA", "BETA", "GPL-2.0"]