summaryrefslogtreecommitdiff
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:23:09 +0000
commit6984961314c8ba2aceab9acabb658f96ed249fef (patch)
treed865a0b7e764dbaf0d14506693e362ee95234c6a /meta/lib/oe/tests
parent20d4068045c76e9dc2aff0c152dd02d6a109c9dd (diff)
downloadopenembedded-core-6984961314c8ba2aceab9acabb658f96ed249fef.tar.gz
openembedded-core-6984961314c8ba2aceab9acabb658f96ed249fef.tar.bz2
openembedded-core-6984961314c8ba2aceab9acabb658f96ed249fef.zip
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). Signed-off-by: Christopher Larson <kergoth@gmail.com>
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):
with self.assertRaises(oe.license.InvalidLicense) as cm:
self.parse(license)
self.assertEqual(cm.exception.license, license)
+
+class TestSimpleCombinations(unittest.TestCase):
+ tests = {
+ "FOO&BAR": ["FOO", "BAR"],
+ "BAZ & MOO": ["BAZ", "MOO"],
+ "ALPHA|BETA": ["ALPHA"],
+ "BAZ&MOO|FOO": ["FOO"],
+ "FOO&BAR|BAZ": ["FOO", "BAR"],
+ }
+ preferred = ["ALPHA", "FOO", "BAR"]
+
+ def test_tests(self):
+ def choose(a, b):
+ if all(lic in self.preferred for lic in b):
+ return b
+ else:
+ return a
+
+ for license, expected in self.tests.items():
+ licenses = oe.license.flattened_licenses(license, choose)
+ self.assertListEqual(licenses, expected)
+
+class TestComplexCombinations(TestSimpleCombinations):
+ tests = {
+ "FOO & (BAR | BAZ)&MOO": ["FOO", "BAR", "MOO"],
+ "(ALPHA|(BETA&THETA)|OMEGA)&DELTA": ["OMEGA", "DELTA"],
+ "((ALPHA|BETA)&FOO)|BAZ": ["BETA", "FOO"],
+ "(GPL-2.0|Proprietary)&BSD-4-clause&MIT": ["GPL-2.0", "BSD-4-clause", "MIT"],
+ }
+ preferred = ["BAR", "OMEGA", "BETA", "GPL-2.0"]