|
17 | 17 | from scancode.cli_test_utils import check_json_scan
|
18 | 18 | from scancode.cli_test_utils import run_scan_click
|
19 | 19 | from scancode_config import REGEN_TEST_FIXTURES
|
| 20 | +from packagedcode.debian import build_package_data_from_package_filename |
| 21 | +from packagedcode.debian import DebianDebPackageHandler |
20 | 22 |
|
21 | 23 |
|
22 | 24 | @skipIf(on_windows, 'These tests contain files that are not legit on Windows.')
|
@@ -146,3 +148,35 @@ def test_parse_debian_files_list_with_arch(self):
|
146 | 148 |
|
147 | 149 | expected_loc = self.get_test_loc('debian/files-md5sums/mokutil-amd64.md5sums.expected.json', must_exist=False)
|
148 | 150 | self.check_packages_data(results, expected_loc, must_exist=False, regen=REGEN_TEST_FIXTURES)
|
| 151 | + |
| 152 | + def test_build_package_data_from_package_filename_deb_does_not_crash_on_version(self): |
| 153 | + filename = 'libapache2-mod-md_2.4.38-3+deb10u10_amd64.deb' |
| 154 | + result = build_package_data_from_package_filename( |
| 155 | + filename=filename, |
| 156 | + datasource_id='debian_deb', |
| 157 | + package_type='deb', |
| 158 | + ) |
| 159 | + assert str( result. purl) == 'pkg:deb/[email protected]%2Bdeb10u10?architecture=amd64' |
| 160 | + |
| 161 | + def test_build_package_data_from_package_filename_orig_sdoes_not_crash_on_version(self): |
| 162 | + filename = 'abseil_0~20200923.3.orig.tar.gz' |
| 163 | + result = build_package_data_from_package_filename( |
| 164 | + filename=filename, |
| 165 | + datasource_id='debian_deb', |
| 166 | + package_type='deb', |
| 167 | + ) |
| 168 | + assert str(result.purl) == 'pkg:deb/abseil@0~20200923.3' |
| 169 | + |
| 170 | + def test_build_package_data_from_package_filename_debian_tar_sdoes_not_crash_on_version(self): |
| 171 | + filename = 'abseil_20220623.1-1.debian.tar.xz' |
| 172 | + result = build_package_data_from_package_filename( |
| 173 | + filename=filename, |
| 174 | + datasource_id='debian_deb', |
| 175 | + package_type='deb', |
| 176 | + ) |
| 177 | + assert str( result. purl) == 'pkg:deb/[email protected]' |
| 178 | + |
| 179 | + def test_DebianDebPackageHandler_parse_does_not_crash_on_version(self): |
| 180 | + location = 'foo/bar/libapache2-mod-md_2.4.38-3+deb10u10_amd64.deb' |
| 181 | + result = list(DebianDebPackageHandler.parse(location))[0] |
| 182 | + assert str( result. purl) == 'pkg:deb/[email protected]%2Bdeb10u10?architecture=amd64' |
0 commit comments