From ade514bec8463e9ee0a21b0d76caefb904f0a09d Mon Sep 17 00:00:00 2001 From: vBarbaros Date: Mon, 29 Nov 2021 22:55:21 -0500 Subject: [PATCH] Add support for npm-registry purls --- README.md | 7 +- pypurl/purlutils.py | 45 ++++-- setup.py | 4 +- tests/test_bitbucket_purl.py | 6 +- tests/test_github_purl.py | 9 +- tests/test_gitlab_purl.py | 1 + tests/test_npm_purl.py | 261 +++++++++++++++++++++++++++++++++++ tests/test_pypi_purl.py | 7 +- 8 files changed, 318 insertions(+), 22 deletions(-) create mode 100644 tests/test_npm_purl.py diff --git a/README.md b/README.md index 8f48b2f..cd1698c 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ * Gitlab * BitBucket * PyPi +* npm ### Main concepts: @@ -118,11 +119,11 @@ $ pip install -e . $ python -m unittest tests/*.py # Expected output -....................................................................................................... ----------------------------------------------------------------------- -Ran 103 tests in 0.004s +... +Ran 138 tests in 0.009s OK + ``` diff --git a/pypurl/purlutils.py b/pypurl/purlutils.py index 1570f2b..9ff3333 100644 --- a/pypurl/purlutils.py +++ b/pypurl/purlutils.py @@ -43,7 +43,10 @@ def set_type_namespace_name(host_list, purl_dict): if i == 1 and purl_dict['type'] not in __get_types_no_namespaces(): purl_dict['namespace'] = host_list[i] elif i == 1 and purl_dict['type'] in __get_types_no_namespaces(): - purl_dict['namespace'] = '' + if len(host_list) == 3: + purl_dict['namespace'] = host_list[i] + else: + purl_dict['namespace'] = '' purl_postname = host_list[i].split('@') purl_dict['name'] = purl_postname[0] @@ -69,7 +72,7 @@ def build_host_part(purl_dict): if check_is_not_valid_type_namespace_name(purl_dict): return '' - if purl_dict['type'] not in __get_types_no_namespaces(): + if purl_dict['type'] not in __get_types_no_namespaces() or purl_dict['namespace'] != '': purl = 'pkg:' + str(purl_dict['type']) + '/' + str(purl_dict['namespace']) + '/' + str(purl_dict['name']) else: purl = 'pkg:' + str(purl_dict['type']) + '/' + str(purl_dict['name']) @@ -112,23 +115,31 @@ def parse_durl(download_url): purl_dict = {} purl_dict['scheme'] = 'pkg' - type_lst = durl_info_list[0].split('.') - if len(type_lst) < 2: + type_list = durl_info_list[0].split('.') + if len(type_list) < 2: + return {} + purl_dict['type'] = __type_from_host(type_list) + if not purl_dict['type']: return {} - purl_dict['type'] = type_lst[0] if durl_info_list[1] == '': return {} if purl_dict['type'] in __get_types_no_namespaces(): - purl_dict['namespace'] = '' + if __is_npm_with_namespace(durl_info_list, purl_dict): + purl_dict['namespace'] = durl_info_list[2] + else: + purl_dict['namespace'] = '' else: purl_dict['namespace'] = durl_info_list[1] if durl_info_list[2] == '': return {} - purl_dict['name'] = durl_info_list[2] + if __is_npm_with_namespace(durl_info_list, purl_dict): + purl_dict['name'] = durl_info_list[3] + else: + purl_dict['name'] = durl_info_list[2] return purl_dict @@ -179,5 +190,23 @@ def build_purl_dict_from_params_optionals(purl_dict, version, qualifiers, subpat return purl_dict +def __is_npm_with_namespace(durl_info_list, purl_dict): + return purl_dict['type'] == 'npm' and len(durl_info_list) == 6 + + def __get_types_no_namespaces(): - return ['pypi'] + return ['pypi', 'npm'] + +def __type_from_host(type_list): + if 'npmjs' in type_list: + return 'npm' + elif 'github' in type_list: + return 'github' + elif 'gitlab' in type_list: + return 'gitlab' + elif 'pypi' in type_list: + return 'pypi' + elif 'bitbucket' in type_list: + return 'bitbucket' + else: + return '' diff --git a/setup.py b/setup.py index f689e92..ceea61b 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ from setuptools import setup setup(name='pypurl', - version='0.0.2', + version='v0.5.0', python_requires='>=3.6', - description='Implementation of an easy way of building and handling the Package URLs.', + description='Implementation of an easy way to build and handle Package URLs.', author='Victor Barbaros', url='https://github.com/vBarbaros/pypurl', ) diff --git a/tests/test_bitbucket_purl.py b/tests/test_bitbucket_purl.py index e0d34b9..7fb8d4e 100644 --- a/tests/test_bitbucket_purl.py +++ b/tests/test_bitbucket_purl.py @@ -1,9 +1,11 @@ import unittest from pypurl.purl import Purl + class BitbucketPurlTestCase(unittest.TestCase): def setUp(self): self.purl_obj = Purl() + print('Running BitBucket-repository tests... OK') def test_bitbucket_purl_to_dict_version_success(self): purl_with_version = 'pkg:bitbucket/pypy/numpy@4f9778cd49a4' @@ -153,7 +155,8 @@ def test_bitbucket_durl_to_purl_main_success(self): self.assertEqual(r, p) def test_bitbucket_params_to_purl_all_success(self): - r = self.purl_obj.params_to_purl('bitbucket', 'pypy', 'numpy', '4f9778cd49a4', 'param1=one,param2=two', '/src/main/sub-path') + r = self.purl_obj.params_to_purl('bitbucket', 'pypy', 'numpy', '4f9778cd49a4', 'param1=one,param2=two', + '/src/main/sub-path') p = 'pkg:bitbucket/pypy/numpy@4f9778cd49a4?param1=one,param2=two#/src/main/sub-path' self.assertEqual(r, p) @@ -172,5 +175,6 @@ def test_bitbucket_params_to_purl_main_success(self): p = 'pkg:bitbucket/pypy/numpy' self.assertEqual(r, p) + if __name__ == '__main__': unittest.main() diff --git a/tests/test_github_purl.py b/tests/test_github_purl.py index 3214f22..2bffff6 100644 --- a/tests/test_github_purl.py +++ b/tests/test_github_purl.py @@ -1,9 +1,11 @@ import unittest from pypurl.purl import Purl + class GithubPurlTestCase(unittest.TestCase): def setUp(self): self.purl_obj = Purl() + print('Running GitHub-repository tests... OK') def test_github_purl_to_dict_version_success(self): purl_with_version = 'pkg:github/package-url/pypurl-spec@244fd47e07d1004f0aed9c' @@ -153,12 +155,14 @@ def test_github_durl_to_purl_main_success(self): self.assertEqual(r, p) def test_github_params_to_purl_all_success(self): - r = self.purl_obj.params_to_purl('github', 'vBarbaros', 'pypurl', '244fd47e07d1004f0aed9c', 'param1=one,param2=two', '/src/main/sub-path') + r = self.purl_obj.params_to_purl('github', 'vBarbaros', 'pypurl', '244fd47e07d1004f0aed9c', + 'param1=one,param2=two', '/src/main/sub-path') p = 'pkg:github/vBarbaros/pypurl@244fd47e07d1004f0aed9c?param1=one,param2=two#/src/main/sub-path' self.assertEqual(r, p) def test_github_params_to_purl_version_qualifier_success(self): - r = self.purl_obj.params_to_purl('github', 'vBarbaros', 'pypurl', '244fd47e07d1004f0aed9c', 'param1=one,param2=two') + r = self.purl_obj.params_to_purl('github', 'vBarbaros', 'pypurl', '244fd47e07d1004f0aed9c', + 'param1=one,param2=two') p = 'pkg:github/vBarbaros/pypurl@244fd47e07d1004f0aed9c?param1=one,param2=two' self.assertEqual(r, p) @@ -172,5 +176,6 @@ def test_github_params_to_purl_main_success(self): p = 'pkg:github/vBarbaros/pypurl' self.assertEqual(r, p) + if __name__ == '__main__': unittest.main() diff --git a/tests/test_gitlab_purl.py b/tests/test_gitlab_purl.py index 5850741..d10da2a 100644 --- a/tests/test_gitlab_purl.py +++ b/tests/test_gitlab_purl.py @@ -5,6 +5,7 @@ class GitlabPurlTestCase(unittest.TestCase): def setUp(self): self.purl_obj = Purl() + print('Running GitLab-repository tests... OK') def test_gitlab_purl_to_dict_version_success(self): purl_with_version = 'pkg:gitlab/gitlab-org/gitlab-foss@v14.1.8' diff --git a/tests/test_npm_purl.py b/tests/test_npm_purl.py new file mode 100644 index 0000000..b185145 --- /dev/null +++ b/tests/test_npm_purl.py @@ -0,0 +1,261 @@ +import unittest +from pypurl.purl import Purl + + +class PypiPurlTestCase(unittest.TestCase): + def setUp(self): + self.purl_obj = Purl() + print('Running npm-registry tests... OK') + + def test_npm_purl_to_dict_version_success(self): + purl_with_version = 'pkg:npm/@angular/cli@13.0.3' + r = self.purl_obj.purl_to_dict(purl_with_version) + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '@angular') + self.assertEqual(r['name'], 'cli') + self.assertEqual(r['version'], '13.0.3') + + def test_npm_purl_to_dict_version_no_namespace_success(self): + purl_with_version = 'pkg:npm/swiper@7.3.1' + r = self.purl_obj.purl_to_dict(purl_with_version) + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '') + self.assertEqual(r['name'], 'swiper') + self.assertEqual(r['version'], '7.3.1') + + def test_npm_purl_to_dict_version_qualifier_success(self): + purl_with_version_qualifiers = 'pkg:npm/@angular/cli@13.0.3?param1=one,param2=two' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers) + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '@angular') + self.assertEqual(r['name'], 'cli') + self.assertEqual(r['version'], '13.0.3') + self.assertEqual(r['qualifiers'], 'param1=one,param2=two') + + def test_npm_purl_to_dict_version_qualifier_no_namespace_success(self): + purl_with_version_qualifiers = 'pkg:npm/swiper@7.3.1?param1=one,param2=two' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers) + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '') + self.assertEqual(r['name'], 'swiper') + self.assertEqual(r['version'], '7.3.1') + self.assertEqual(r['qualifiers'], 'param1=one,param2=two') + + def test_npm_purl_to_dict_version_qualifier_path_success(self): + purl_with_version_qualifiers_subpath = 'pkg:npm/@angular/cli@13.0.3?param1=one,param2=two#/src/main/sub-path' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '@angular') + self.assertEqual(r['name'], 'cli') + self.assertEqual(r['version'], '13.0.3') + self.assertEqual(r['qualifiers'], 'param1=one,param2=two') + self.assertEqual(r['subpath'], '/src/main/sub-path') + + def test_npm_purl_to_dict_version_qualifier_path_no_namespace_success(self): + purl_with_version_qualifiers_subpath = 'pkg:npm/swiper@7.3.1?param1=one,param2=two#/src/main/sub-path' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '') + self.assertEqual(r['name'], 'swiper') + self.assertEqual(r['version'], '7.3.1') + self.assertEqual(r['qualifiers'], 'param1=one,param2=two') + self.assertEqual(r['subpath'], '/src/main/sub-path') + + def test_npm_purl_to_dict_no_pkg_fail(self): + purl_with_version_qualifiers_subpath = 'npm/swiper@7.3.1?param1=one,param2=two#/src/main/sub-path' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) + self.assertEqual(r, {}) + + def test_npm_purl_to_dict_no_type_fail(self): + purl_with_version_qualifiers_subpath = 'pkg:swiper@7.3.1?param1=one,param2=two#/src/main/sub-path' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) + self.assertEqual(r, {}) + + def test_npm_purl_to_dict_no_name_fail(self): + purl_with_version_qualifiers_subpath = 'pkg:npm@7.3.1?param1=one,param2=two#/src/main/sub-path' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) + self.assertEqual(r, {}) + + def test_npm_purl_to_dict_no_type_wrong_url_fail(self): + purl_with_version_qualifiers_subpath = 'pkg:/swiper@7.3.1?param1=one,param2=two#/src/main/sub-path' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) + self.assertEqual(r, {}) + + def test_npm_purl_to_dict_no_name_wrong_url_fail(self): + purl_with_version_qualifiers_subpath = 'pkg:npm/@7.3.1?param1=one,param2=two#/src/main/sub-path' + r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) + self.assertEqual(r, {}) + + def test_npm_durl_to_dict_all_no_namespace_success(self): + durl = 'https://www.npmjs.com/package/swiper/v/7.3.1' + r = self.purl_obj.durl_to_dict(durl, '7.3.1', 'param1=one,param2=two', '/src/main/sub-path') + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '') + self.assertEqual(r['name'], 'swiper') + self.assertEqual(r['version'], '7.3.1') + self.assertEqual(r['qualifiers'], 'param1=one,param2=two') + self.assertEqual(r['subpath'], '/src/main/sub-path') + + def test_npm_durl_to_dict_all_success(self): + durl = 'https://www.npmjs.com/package/@angular/cli/v/13.0.3' + r = self.purl_obj.durl_to_dict(durl, '13.0.3', 'param1=one,param2=two', '/src/main/sub-path') + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '@angular') + self.assertEqual(r['name'], 'cli') + self.assertEqual(r['version'], '13.0.3') + self.assertEqual(r['qualifiers'], 'param1=one,param2=two') + self.assertEqual(r['subpath'], '/src/main/sub-path') + + def test_npm_durl_to_dict_version_qualifier_success(self): + durl = 'https://www.npmjs.com/package/@angular/cli/v/13.0.3' + r = self.purl_obj.durl_to_dict(durl, '13.0.3', 'param1=one,param2=two') + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '@angular') + self.assertEqual(r['name'], 'cli') + self.assertEqual(r['version'], '13.0.3') + self.assertEqual(r['qualifiers'], 'param1=one,param2=two') + + def test_npm_durl_to_dict_version_qualifier_no_namespace_success(self): + durl = 'https://www.npmjs.com/package/swiper/v/7.3.1' + r = self.purl_obj.durl_to_dict(durl, '7.3.1', 'param1=one,param2=two') + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '') + self.assertEqual(r['name'], 'swiper') + self.assertEqual(r['version'], '7.3.1') + self.assertEqual(r['qualifiers'], 'param1=one,param2=two') + + def test_npm_durl_to_dict_version_success(self): + durl = 'https://www.npmjs.com/package/@angular/cli/v/13.0.3' + r = self.purl_obj.durl_to_dict(durl, '13.0.3') + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '@angular') + self.assertEqual(r['name'], 'cli') + self.assertEqual(r['version'], '13.0.3') + + def test_npm_durl_to_dict_version_no_namespace_success(self): + durl = 'https://www.npmjs.com/package/swiper/v/7.3.1' + r = self.purl_obj.durl_to_dict(durl, '7.3.1') + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '') + self.assertEqual(r['name'], 'swiper') + self.assertEqual(r['version'], '7.3.1') + + def test_npm_durl_to_dict_main_success(self): + durl = 'https://www.npmjs.com/package/@angular/cli/v/13.0.3' + r = self.purl_obj.durl_to_dict(durl) + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '@angular') + self.assertEqual(r['name'], 'cli') + + def test_npm_durl_to_dict_main_no_namespace_success(self): + durl = 'https://www.npmjs.com/package/swiper/v/7.3.1' + r = self.purl_obj.durl_to_dict(durl) + self.assertEqual(r['scheme'], 'pkg') + self.assertEqual(r['type'], 'npm') + self.assertEqual(r['namespace'], '') + self.assertEqual(r['name'], 'swiper') + + def test_npm_durl_to_dict_main_wrong_http_fail(self): + durl = 'https:www.npmjs.com/package/swiper/v/7.3.1' + r = self.purl_obj.durl_to_dict(durl) + self.assertEqual(r, {}) + + def test_npm_durl_to_dict_main_wrong_type_fail(self): + durl = 'https://npmjs/package/swiper/v/7.3.1' + r = self.purl_obj.durl_to_dict(durl) + self.assertEqual(r, {}) + + def test_npm_durl_to_dict_main_wrong_namespace_fail(self): + durl = 'https://www.npmjs.com/package//swiper/v/7.3.1' + r = self.purl_obj.durl_to_dict(durl) + self.assertEqual(r, {}) + + def test_npm_durl_to_dict_main_wrong_name_fail(self): + durl = 'https://www.npmjs.com/package//v/7.3.1' + r = self.purl_obj.durl_to_dict(durl) + self.assertEqual(r, {}) + + def test_npm_durl_to_purl_all_success(self): + durl = 'https://www.npmjs.com/package/@angular/cli/v/13.0.3' + actual = self.purl_obj.durl_to_purl(durl, '13.0.3', 'param1=one,param2=two', '/src/main/sub-path') + expect = 'pkg:npm/@angular/cli@13.0.3?param1=one,param2=two#/src/main/sub-path' + self.assertEqual(expect, actual) + + def test_npm_durl_to_purl_all_no_namespace_success(self): + durl = 'https://www.npmjs.com/package/swiper/v/7.3.1' + actual = self.purl_obj.durl_to_purl(durl, '7.3.1', 'param1=one,param2=two', '/src/main/sub-path') + expect = 'pkg:npm/swiper@7.3.1?param1=one,param2=two#/src/main/sub-path' + self.assertEqual(expect, actual) + + def test_npm_durl_to_purl_version_qualifier_success(self): + durl = 'https://www.npmjs.com/package/@angular/cli/v/13.0.3' + actual = self.purl_obj.durl_to_purl(durl, '13.0.3', 'param1=one,param2=two') + expect = 'pkg:npm/@angular/cli@13.0.3?param1=one,param2=two' + self.assertEqual(expect, actual) + + def test_npm_durl_to_purl_version_qualifier_no_namespace_success(self): + durl = 'https://www.npmjs.com/package/swiper/v/7.3.1' + actual = self.purl_obj.durl_to_purl(durl, '7.3.1', 'param1=one,param2=two') + expect = 'pkg:npm/swiper@7.3.1?param1=one,param2=two' + self.assertEqual(expect, actual) + + def test_npm_durl_to_purl_version_success(self): + durl = 'https://www.npmjs.com/package/@angular/cli/v/13.0.3' + actual = self.purl_obj.durl_to_purl(durl, '13.0.3') + expect = 'pkg:npm/@angular/cli@13.0.3' + self.assertEqual(expect, actual) + + def test_npm_durl_to_purl_version_no_namespace_success(self): + durl = 'https://www.npmjs.com/package/swiper/v/7.3.1' + actual = self.purl_obj.durl_to_purl(durl, '7.3.1') + expect = 'pkg:npm/swiper@7.3.1' + self.assertEqual(expect, actual) + + def test_npm_durl_to_purl_main_success(self): + durl = 'https://www.npmjs.com/package/@angular/cli/v/13.0.3' + actual = self.purl_obj.durl_to_purl(durl) + expect = 'pkg:npm/@angular/cli' + self.assertEqual(expect, actual) + + def test_npm_durl_to_purl_main_no_namespace_success(self): + durl = 'https://www.npmjs.com/package/swiper/v/7.3.1' + actual = self.purl_obj.durl_to_purl(durl) + expect = 'pkg:npm/swiper' + self.assertEqual(expect, actual) + + def test_npm_params_to_purl_all_success(self): + r = self.purl_obj.params_to_purl('npm', '', 'swiper', '7.3.1', 'param1=one,param2=two', '/src/main/sub-path') + p = 'pkg:npm/swiper@7.3.1?param1=one,param2=two#/src/main/sub-path' + self.assertEqual(r, p) + + def test_npm_params_to_purl_version_qualifier_success(self): + r = self.purl_obj.params_to_purl('npm', '', 'swiper', '7.3.1', 'param1=one,param2=two') + p = 'pkg:npm/swiper@7.3.1?param1=one,param2=two' + self.assertEqual(r, p) + + def test_npm_params_to_purl_version_success(self): + r = self.purl_obj.params_to_purl('npm', '', 'swiper', '7.3.1') + p = 'pkg:npm/swiper@7.3.1' + self.assertEqual(r, p) + + def test_npm_params_to_purl_main_success(self): + r = self.purl_obj.params_to_purl('npm', '', 'swiper') + p = 'pkg:npm/swiper' + self.assertEqual(r, p) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_pypi_purl.py b/tests/test_pypi_purl.py index df4e16e..4643527 100644 --- a/tests/test_pypi_purl.py +++ b/tests/test_pypi_purl.py @@ -5,6 +5,7 @@ class PypiPurlTestCase(unittest.TestCase): def setUp(self): self.purl_obj = Purl() + print('Running pypi-repository tests... OK') def test_pypi_purl_to_dict_version_success(self): purl_with_version = 'pkg:pypi/notificationcenter@1.0.0b2' @@ -47,9 +48,6 @@ def test_pypi_purl_to_dict_no_type_fail(self): self.assertEqual(r, {}) def test_pypi_purl_to_dict_no_namespace_success(self): - """ - This use-case represents the optional namespace field in cases of pypi repository. - """ purl_with_version_qualifiers_subpath = 'pkg:pypi/notificationcenter@1.0.0b2?param1=one,param2=two#/src/main/sub-path' r = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) self.assertEqual(r['scheme'], 'pkg') @@ -77,7 +75,6 @@ def test_pypi_purl_to_dict_no_name_wrong_url_fail(self): def test_pypi_durl_to_dict_all_success(self): durl = 'https://pypi.org/project/notificationcenter/1.0.0b2/' - 'pkg:pypi/notificationcenter@1.0.0b2' r = self.purl_obj.durl_to_dict(durl, '1.0.0b2', 'param1=one,param2=two', '/src/main/sub-path') self.assertEqual(r['scheme'], 'pkg') self.assertEqual(r['type'], 'pypi') @@ -89,7 +86,6 @@ def test_pypi_durl_to_dict_all_success(self): def test_pypi_durl_to_dict_version_qualifier_success(self): durl = 'https://pypi.org/project/notificationcenter/1.0.0b2/' - 'pkg:pypi/notificationcenter@1.0.0b2' r = self.purl_obj.durl_to_dict(durl, '1.0.0b2', 'param1=one,param2=two') self.assertEqual(r['scheme'], 'pkg') self.assertEqual(r['type'], 'pypi') @@ -100,7 +96,6 @@ def test_pypi_durl_to_dict_version_qualifier_success(self): def test_pypi_durl_to_dict_version_success(self): durl = 'https://pypi.org/project/notificationcenter/1.0.0b2/' - 'pkg:pypi/notificationcenter@1.0.0b2' r = self.purl_obj.durl_to_dict(durl, '1.0.0b2') self.assertEqual(r['scheme'], 'pkg') self.assertEqual(r['type'], 'pypi')