Skip to content

Commit 412ea31

Browse files
committed
Update test cases upto expectation
Signed-off-by: akugarg <akanksha.garg2k@gmail.com>
1 parent ccf9de4 commit 412ea31

6 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/summarycode/plugin_consolidate.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ def get_holders_consolidated_components(codebase):
338338
if license_expression:
339339
child.extra_data['normalized_license_expression'] = license_expression
340340
child.save(codebase)
341+
if "unknown" in license_expression:
342+
child.extra_data['normalized_unknown_license_expression'] = license_expression
343+
child.save(codebase)
341344

342345
if child.holders:
343346
holders = process_holders(h['value'] for h in child.holders)
@@ -383,15 +386,19 @@ def create_consolidated_components(resource, codebase, holder_key):
383386
given resource and holder key
384387
"""
385388
license_expressions = []
389+
unknwown_expressions = []
386390
holder = None
387391
resources = []
388392
for r in resource.walk(codebase):
389393
for normalized_holder in r.extra_data.get('normalized_holders', []):
390394
if not (normalized_holder.key == holder_key):
391395
continue
392396
normalized_license_expression = r.extra_data.get('normalized_license_expression')
397+
normalized_unknown_license_expression = r.extra_data.get('normalized_unknown_license_expression')
393398
if normalized_license_expression:
394399
license_expressions.append(normalized_license_expression)
400+
if normalized_unknown_license_expression:
401+
unknwown_expressions.append(normalized_unknown_license_expression)
395402
if not holder:
396403
holder = normalized_holder
397404
resources.append(r)
@@ -404,6 +411,7 @@ def create_consolidated_components(resource, codebase, holder_key):
404411

405412
c = Consolidation(
406413
core_license_expression=combine_expressions(license_expressions),
414+
other_license_expression = combine_expressions(unknwown_expressions),
407415
core_holders=[holder],
408416
files_count=len([r for r in resources if r.is_file]),
409417
resources=resources,

tests/summarycode/data/plugin_consolidate/e2fsprogs-expected.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@
676676
"core_holders": [
677677
"Free Software Foundation, Inc. Michel Robitaille"
678678
],
679-
"other_license_expression": null,
679+
"other_license_expression": "free-unknown",
680680
"other_holders": [],
681681
"files_count": 1
682682
},
@@ -692,7 +692,7 @@
692692
"core_holders": [
693693
"Free Software Foundation, Inc."
694694
],
695-
"other_license_expression": null,
695+
"other_license_expression": "(gpl-3.0-plus WITH autoconf-simple-exception AND free-unknown) AND (gpl-2.0-plus AND free-unknown) AND free-unknown",
696696
"other_holders": [],
697697
"files_count": 63
698698
},
@@ -1140,7 +1140,7 @@
11401140
"core_holders": [
11411141
"Theodore Ts'o"
11421142
],
1143-
"other_license_expression": null,
1143+
"other_license_expression": "free-unknown",
11441144
"other_holders": [],
11451145
"files_count": 272
11461146
},

tests/summarycode/data/plugin_consolidate/license-holder-rollup-expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
{
4040
"type": "holders",
4141
"identifier": "corp_oracle_1",
42-
"consolidated_license_expression": "apache-2.0 AND unknown-license-reference",
42+
"consolidated_license_expression": "apache-2.0",
4343
"consolidated_holders": [
4444
"Oracle Corp."
4545
],
4646
"consolidated_copyright": "Copyright (c) Oracle Corp.",
47-
"core_license_expression": "unknown-license-reference AND apache-2.0",
47+
"core_license_expression": "apache-2.0",
4848
"core_holders": [
4949
"Oracle Corp."
5050
],

tests/summarycode/data/plugin_consolidate/return-nested-local-majority-expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
{
2424
"type": "holders",
2525
"identifier": "apache_foundation_software_1",
26-
"consolidated_license_expression": "apache-2.0 AND unknown-license-reference",
26+
"consolidated_license_expression": "apache-2.0",
2727
"consolidated_holders": [
2828
"The Apache Software Foundation"
2929
],
3030
"consolidated_copyright": "Copyright (c) The Apache Software Foundation",
31-
"core_license_expression": "unknown-license-reference AND apache-2.0",
31+
"core_license_expression": "apache-2.0",
3232
"core_holders": [
3333
"The Apache Software Foundation"
3434
],

tests/summarycode/data/plugin_consolidate/zlib-expected.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@
284284
"core_holders": [
285285
"Cosmin Truta"
286286
],
287-
"other_license_expression": null,
287+
"other_license_expression": "unknown-license-reference",
288288
"other_holders": [],
289289
"files_count": 3
290290
},

tests/summarycode/data/score/file_coverage-expected.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@
158158
}
159159
}
160160
],
161+
"unknown_licenses": [],
161162
"license_expressions": [
162163
"mit"
163164
],
165+
"unknown_license_expressions": [],
164166
"percentage_of_license_text": 1.83,
165167
"copyrights": [],
166168
"holders": [],
@@ -274,9 +276,11 @@
274276
}
275277
}
276278
],
279+
"unknown_licenses": [],
277280
"license_expressions": [
278281
"mit"
279282
],
283+
"unknown_license_expressions": [],
280284
"percentage_of_license_text": 33.33,
281285
"copyrights": [
282286
{

0 commit comments

Comments
 (0)