|
16 | 16 |
|
17 | 17 | from packagedcode import rpm
|
18 | 18 | from scancode_config import REGEN_TEST_FIXTURES
|
| 19 | +from packages_test_utils import check_result_equals_expected_json |
| 20 | + |
19 | 21 |
|
20 | 22 | class TestRpmBasics(FileBasedTesting):
|
21 | 23 | test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
|
22 | 24 |
|
23 | 25 | def test_parse_to_package(self):
|
24 | 26 | 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) |
113 | 35 |
|
114 | 36 | def test_pyrpm_basic(self):
|
115 | 37 | test_file = self.get_test_loc('rpm/header/python-glc-0.7.1-1.src.rpm')
|
|
0 commit comments