Skip to content

Commit

Permalink
Fix tests and add new tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
  • Loading branch information
AyanSinhaMahapatra committed Jun 7, 2023
1 parent c86490d commit 55aac5d
Show file tree
Hide file tree
Showing 30 changed files with 17,341 additions and 1,960 deletions.
8 changes: 8 additions & 0 deletions src/packagedcode/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

from commoncode import fileutils

from licensedcode.cache import build_spdx_license_expression
from licensedcode.cache import get_cache
from licensedcode.tokenize import query_tokenizer
from licensedcode.detection import detect_licenses
from licensedcode.detection import get_unknown_license_detection
Expand Down Expand Up @@ -122,6 +124,11 @@ def assemble(cls, package_data, resource, codebase, package_adder):
resource=resource,
codebase=codebase,
)
if package.declared_license_expression:
package.declared_license_expression_spdx = str(build_spdx_license_expression(
license_expression=package.declared_license_expression,
licensing=get_cache().licensing,
))

cls.assign_package_to_resources(
package=package,
Expand All @@ -132,6 +139,7 @@ def assemble(cls, package_data, resource, codebase, package_adder):

yield package


# we yield this as we do not want this further processed
yield resource

Expand Down
26 changes: 3 additions & 23 deletions tests/packagedcode/data/build/buck/end2end-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,29 +247,9 @@
"vcs_url": null,
"copyright": null,
"holder": null,
"declared_license_expression": "apache-2.0",
"declared_license_expression_spdx": "Apache-2.0",
"license_detections": [
{
"license_expression": "apache-2.0",
"matches": [
{
"score": 100.0,
"start_line": 1,
"end_line": 1,
"matched_length": 3,
"match_coverage": 100.0,
"matcher": "1-hash",
"license_expression": "apache-2.0",
"rule_identifier": "spdx_license_id_apache-2.0_for_apache-2.0.RULE",
"rule_relevance": 100,
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/spdx_license_id_apache-2.0_for_apache-2.0.RULE",
"matched_text": "apache-2.0"
}
],
"identifier": "apache_2_0-d66ab77d-a5cc-7104-e702-dc7df61fe9e8"
}
],
"declared_license_expression": null,
"declared_license_expression_spdx": null,
"license_detections": [],
"other_license_expression": null,
"other_license_expression_spdx": null,
"other_license_detections": [],
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 55aac5d

Please sign in to comment.