@@ -98,39 +98,39 @@ def test_LicenseSymbol(self):
98
98
99
99
def test_python_operators_simple (self ):
100
100
licensing = Licensing ()
101
-
101
+
102
102
sym1 = LicenseSymbol ('MIT' )
103
103
sym2 = LicenseSymbol ('BSD-2' )
104
-
104
+
105
105
assert sym1 & sym2 == licensing .AND (sym1 , sym2 )
106
106
assert sym1 | sym2 == licensing .OR (sym1 , sym2 )
107
-
107
+
108
108
sym3 = LicenseWithExceptionSymbol (LicenseSymbol ("GPL-3.0-or-later" ), LicenseSymbol ("GCC-exception-3.1" ))
109
-
109
+
110
110
# Make sure LicenseWithExceptionSymbol operation work on left and right side
111
111
assert sym3 & sym1 == licensing .AND (sym3 , sym1 )
112
112
assert sym1 & sym3 == licensing .AND (sym1 , sym3 )
113
113
assert sym3 | sym1 == licensing .OR (sym3 , sym1 )
114
114
assert sym1 | sym3 == licensing .OR (sym3 , sym1 )
115
-
115
+
116
116
def test_boolean_expression_operators (self ):
117
-
117
+
118
118
# Make sure LicenseWithExceptionSymbol boolean expression are set
119
119
assert LicenseWithExceptionSymbol .Symbol is not None
120
120
assert LicenseWithExceptionSymbol .TRUE is not None
121
121
assert LicenseWithExceptionSymbol .FALSE is not None
122
122
assert LicenseWithExceptionSymbol .AND is not None
123
123
assert LicenseWithExceptionSymbol .OR is not None
124
124
assert LicenseWithExceptionSymbol .NOT is not None
125
-
125
+
126
126
# Make sure LicenseWithExceptionSymbol matches LicenseSymbol
127
127
assert LicenseWithExceptionSymbol .Symbol == LicenseSymbol
128
128
assert LicenseWithExceptionSymbol .TRUE == LicenseSymbol .TRUE
129
129
assert LicenseWithExceptionSymbol .FALSE == LicenseSymbol .FALSE
130
130
assert LicenseWithExceptionSymbol .AND == LicenseSymbol .AND
131
131
assert LicenseWithExceptionSymbol .OR == LicenseSymbol .OR
132
132
assert LicenseWithExceptionSymbol .NOT == LicenseSymbol .NOT
133
-
133
+
134
134
135
135
136
136
class LicensingTest (TestCase ):
@@ -2433,53 +2433,32 @@ class UtilTest(TestCase):
2433
2433
test_data_dir = join (dirname (__file__ ), 'data' )
2434
2434
2435
2435
def test_build_licensing (self ):
2436
- test_license_index_location = join (
2437
- self .test_data_dir , 'test_license_key_index.json' )
2438
- with open (test_license_index_location ) as f :
2439
- license_info = json .load (f )
2440
- lics = [
2441
- {
2442
- 'key' : l .get ('license_key' , '' ),
2443
- 'is_exception' : l .get ('is_exception' , '' ),
2444
- } for l in license_info if l .get ('spdx_license_key' )
2445
- ]
2446
- syms = [LicenseSymbol (** l ) for l in lics ]
2447
- expected = Licensing (syms )
2448
-
2449
- test_license_index = get_license_index (
2450
- license_index_location = test_license_index_location )
2436
+ test_license_index_location = join (self .test_data_dir , "test_license_key_index.json" )
2437
+ test_license_index = get_license_index (license_index_location = test_license_index_location )
2451
2438
result = build_licensing (test_license_index )
2452
2439
2453
- assert result .known_symbols == expected .known_symbols
2454
- assert result .known_symbols_lowercase == expected .known_symbols_lowercase
2455
- # Ensure deprecated licenses are not loaded
2456
- assert 'aladdin-md5' not in result .known_symbols
2457
- assert 'aladdin-md5' not in result .known_symbols_lowercase
2440
+ known_symbols = set (result .known_symbols .keys ())
2441
+ known_symbols_lowercase = set (result .known_symbols_lowercase .keys ())
2442
+ expected_symbols = {"389-exception" , "3com-microcode" , "3dslicer-1.0" , "aladdin-md5" }
2458
2443
2459
- def test_build_spdx_licensing (self ):
2460
- test_license_index_location = join (
2461
- self .test_data_dir , 'test_license_key_index.json' )
2462
- with open (test_license_index_location ) as f :
2463
- license_info = json .load (f )
2464
- lics = [
2465
- {
2466
- 'key' : l .get ('spdx_license_key' , '' ),
2467
- 'aliases' : l .get ('other_spdx_license_keys' , '' ),
2468
- 'is_exception' : l .get ('is_exception' , '' ),
2469
- } for l in license_info if l .get ('spdx_license_key' )
2470
- ]
2471
- syms = [LicenseSymbol (** l ) for l in lics ]
2472
- expected = Licensing (syms )
2444
+ assert known_symbols == expected_symbols
2445
+ assert known_symbols_lowercase == {sym .lower () for sym in expected_symbols }
2473
2446
2474
- test_license_index = get_license_index (
2475
- license_index_location = test_license_index_location )
2447
+ def test_build_spdx_licensing (self ):
2448
+ test_license_index_location = join (self .test_data_dir , "test_license_key_index.json" )
2449
+ test_license_index = get_license_index (license_index_location = test_license_index_location )
2476
2450
result = build_spdx_licensing (test_license_index )
2477
2451
2478
- assert result .known_symbols == expected .known_symbols
2479
- assert result .known_symbols_lowercase == expected .known_symbols_lowercase
2480
- # Ensure deprecated licenses are not loaded
2481
- assert 'aladdin-md5' not in result .known_symbols
2482
- assert 'aladdin-md5' not in result .known_symbols_lowercase
2452
+ known_symbols = set (result .known_symbols .keys ())
2453
+ known_symbols_lowercase = set (result .known_symbols_lowercase .keys ())
2454
+ expected_symbols = {
2455
+ "389-exception" ,
2456
+ "LicenseRef-scancode-3com-microcode" ,
2457
+ "LicenseRef-scancode-3dslicer-1.0" ,
2458
+ }
2459
+
2460
+ assert known_symbols == expected_symbols
2461
+ assert known_symbols_lowercase == {sym .lower () for sym in expected_symbols }
2483
2462
2484
2463
def test_get_license_key_info (self ):
2485
2464
test_license_index_location = join (
0 commit comments