Skip to content

Commit f27e61c

Browse files
committed
Update test expectations for RPMs
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent ccef6f8 commit f27e61c

File tree

2 files changed

+84
-88
lines changed

2 files changed

+84
-88
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[
2+
{
3+
"type": "rpm",
4+
"namespace": null,
5+
"name": "libproxy-bin",
6+
"version": "0.3.0-4.el6_3",
7+
"qualifiers": {},
8+
"subpath": null,
9+
"primary_language": null,
10+
"description": "Binary to test libproxy\nThe libproxy-bin package contains the proxy binary for libproxy",
11+
"release_date": null,
12+
"parties": [
13+
{
14+
"type": null,
15+
"role": "vendor",
16+
"name": "CentOS",
17+
"email": null,
18+
"url": null
19+
}
20+
],
21+
"keywords": [],
22+
"homepage_url": "http://code.google.com/p/libproxy/",
23+
"download_url": null,
24+
"size": null,
25+
"sha1": null,
26+
"md5": null,
27+
"sha256": null,
28+
"sha512": null,
29+
"bug_tracking_url": null,
30+
"code_view_url": null,
31+
"vcs_url": null,
32+
"copyright": null,
33+
"declared_license_expression": "lgpl-2.0-plus",
34+
"declared_license_expression_spdx": "LGPL-2.0-or-later",
35+
"license_detections": [
36+
{
37+
"license_expression": "lgpl-2.0-plus",
38+
"detection_log": [
39+
"not-combined"
40+
],
41+
"matches": [
42+
{
43+
"score": 100.0,
44+
"start_line": 1,
45+
"end_line": 1,
46+
"matched_length": 1,
47+
"match_coverage": 100.0,
48+
"matcher": "1-hash",
49+
"license_expression": "lgpl-2.0-plus",
50+
"rule_identifier": "lgpl-2.0-plus_68.RULE",
51+
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-2.0-plus_68.RULE",
52+
"matched_text": "LGPLv2+"
53+
}
54+
]
55+
}
56+
],
57+
"other_license_expression": null,
58+
"other_license_expression_spdx": null,
59+
"other_license_detections": [],
60+
"extracted_license_statement": "LGPLv2+",
61+
"notice_text": null,
62+
"source_packages": [
63+
"pkg:rpm/libproxy@0.3.0-4.el6_3?arch=src"
64+
],
65+
"file_references": [],
66+
"extra_data": {},
67+
"dependencies": [],
68+
"repository_homepage_url": null,
69+
"repository_download_url": null,
70+
"api_data_url": null,
71+
"datasource_id": "rpm_archive",
72+
"purl": "pkg:rpm/libproxy-bin@0.3.0-4.el6_3"
73+
}
74+
]

tests/packagedcode/test_rpm.py

Lines changed: 10 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -16,100 +16,22 @@
1616

1717
from packagedcode import rpm
1818
from scancode_config import REGEN_TEST_FIXTURES
19+
from packages_test_utils import check_result_equals_expected_json
20+
1921

2022
class TestRpmBasics(FileBasedTesting):
2123
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
2224

2325
def test_parse_to_package(self):
2426
test_file = self.get_test_loc('rpm/header/libproxy-bin-0.3.0-4.el6_3.x86_64.rpm')
25-
for package_data in rpm.RpmArchiveHandler.parse(test_file):
26-
break
27-
28-
expected = [
29-
('type', 'rpm'),
30-
('namespace', None),
31-
('name', 'libproxy-bin'),
32-
('version', '0.3.0-4.el6_3'),
33-
('qualifiers', {}),
34-
('subpath', None),
35-
('primary_language', None),
36-
('description',
37-
'Binary to test libproxy\n'
38-
'The libproxy-bin package contains the proxy binary for libproxy'),
39-
('release_date', None),
40-
('parties', [
41-
dict([
42-
('type', None),
43-
('role', 'vendor'),
44-
('name', 'CentOS'),
45-
('email', None),
46-
('url', None)])
47-
]),
48-
('keywords', []),
49-
('homepage_url', 'http://code.google.com/p/libproxy/'),
50-
('download_url', None),
51-
('size', None),
52-
('sha1', None),
53-
('md5', None),
54-
('sha256', None),
55-
('sha512', None),
56-
('bug_tracking_url', None),
57-
('code_view_url', None),
58-
('vcs_url', None),
59-
('copyright', None),
60-
('declared_license_expression', 'lgpl-2.0-plus'),
61-
('declared_license_expression_spdx', 'LGPL-2.0-or-later'),
62-
('license_detections',
63-
[{'detection_log': ['not-combined'],
64-
'license_expression': 'lgpl-2.0-plus',
65-
'matches': [{'end_line': 1,
66-
'is_license_intro': False,
67-
'is_license_notice': False,
68-
'is_license_reference': True,
69-
'is_license_tag': False,
70-
'is_license_text': False,
71-
'license_expression': 'lgpl-2.0-plus',
72-
'rule_identifier': 'lgpl-2.0-plus_68.RULE',
73-
'rule_url': 'https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/lgpl-2.0-plus_68.RULE',
74-
'licenses': [{'category': 'Copyleft Limited',
75-
'homepage_url': 'http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html',
76-
'is_exception': False,
77-
'is_unknown': False,
78-
'key': 'lgpl-2.0-plus',
79-
'name': 'GNU Library General Public License 2.0 '
80-
'or later',
81-
'owner': 'Free Software Foundation (FSF)',
82-
'reference_url': 'https://scancode-licensedb.aboutcode.org/lgpl-2.0-plus',
83-
'scancode_url': 'https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/lgpl-2.0-plus.LICENSE',
84-
'short_name': 'LGPL 2.0 or later',
85-
'spdx_license_key': 'LGPL-2.0-or-later',
86-
'spdx_url': 'https://spdx.org/licenses/LGPL-2.0-or-later',
87-
'text_url': 'http://www.gnu.org/licenses/old-licenses/lgpl-2.0-standalone.html'}],
88-
'match_coverage': 100.0,
89-
'matched_length': 1,
90-
'matched_text': 'LGPLv2+',
91-
'matcher': '1-hash',
92-
'referenced_filenames': [],
93-
'rule_length': 1,
94-
'rule_relevance': 100,
95-
'score': 100.0,
96-
'start_line': 1}]}]),
97-
('other_license_expression', None),
98-
('other_license_expression_spdx', None),
99-
('other_license_detections', []),
100-
('extracted_license_statement', 'LGPLv2+'),
101-
('notice_text', None),
102-
('source_packages', [ 'pkg:rpm/libproxy@0.3.0-4.el6_3?arch=src']),
103-
('file_references', []),
104-
('extra_data', {}),
105-
('dependencies', []),
106-
('repository_homepage_url', None),
107-
('repository_download_url', None),
108-
('api_data_url', None),
109-
('datasource_id', 'rpm_archive'),
110-
('purl', 'pkg:rpm/libproxy-bin@0.3.0-4.el6_3'),
111-
]
112-
assert list(package_data.to_dict().items()) == expected
27+
package_datas = rpm.RpmArchiveHandler.parse(test_file)
28+
result = [pd.to_dict() for pd in package_datas]
29+
30+
expected_loc = self.get_test_loc(
31+
'rpm/header/libproxy-bin-0.3.0-4.el6_3.x86_64.rpm-package-expected.json',
32+
must_exist=False,
33+
)
34+
check_result_equals_expected_json(result, expected_loc, regen=REGEN_TEST_FIXTURES)
11335

11436
def test_pyrpm_basic(self):
11537
test_file = self.get_test_loc('rpm/header/python-glc-0.7.1-1.src.rpm')

0 commit comments

Comments
 (0)