Skip to content

Commit

Permalink
Merge pull request #17 from NexSabre/fix-16
Browse files Browse the repository at this point in the history
Fix issue with creating a packages with the dash inside name.
  • Loading branch information
NexSabre authored Jul 19, 2022
2 parents f2506ab + f0fc1e3 commit a9702f1
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

# 1.4
- Resolve issue #16 (@Spedoske) with wrong split package name
- Resolve issue #15 (@salotz-sitx) with wrong version of the MarkupSafe

# 1.3-alpha.0
_Note: Version v1.2 was revoked due to incorrect numeration (missing alpha tag could mislead that this is the final version)_

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3-alpha.1
1.4
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest==7.1.2
pytest-mock==3.8.2
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests==2.22.0
jinja2~=2.11.0
jinja2==2.11.0
dataclasses==0.6
markupsafe==2.0.1
5 changes: 2 additions & 3 deletions src/pip2spack/core/pypi_package.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import json
from typing import List
from urllib.request import Request

import requests
from jinja2 import Environment, PackageLoader, select_autoescape, FileSystemLoader
from jinja2 import Environment, PackageLoader, FileSystemLoader

from pip2spack.framework.messages import Messages

Expand Down Expand Up @@ -61,7 +60,7 @@ def _generate_pypi_uri(filename_with_version):
if not filename_with_version:
raise Exception("Can not generate a proper master link to the package")
return f'https://pypi.io/packages/source/{filename_with_version[0]}/' \
f'{filename_with_version.split("-")[0]}/{filename_with_version}'
f'{"-".join(filename_with_version.split("-")[:-1])}/{filename_with_version}'

if source:
for url in self.content["urls"]:
Expand Down
Empty file added tests/__init__.py
Empty file.
Empty file added tests/pip2spack/__init__.py
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions tests/pip2spack/core/test_pypi_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
import json
from src.pip2spack.core.pypi_package import PyPiPackage

PYPI_CONFIGSHELL_FB_MOCK = """{"info": {"author": "", "author_email": "", "bugtrack_url": null, "classifiers": ["License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3"], "description": "", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": {"last_day": -1, "last_month": -1, "last_week": -1}, "home_page": "http://github.com/open-iscsi/configshell-fb", "keywords": "", "license": "Apache 2.0", "maintainer": "Andy Grover", "maintainer_email": "[email protected]", "name": "configshell-fb", "package_url": "https://pypi.org/project/configshell-fb/", "platform": "", "project_url": "https://pypi.org/project/configshell-fb/", "project_urls": {"Homepage": "http://github.com/open-iscsi/configshell-fb"}, "release_url": "https://pypi.org/project/configshell-fb/1.1.29/", "requires_dist": null, "requires_python": "", "summary": "A framework to implement simple but nice CLIs.", "version": "1.1.29", "yanked": false, "yanked_reason": null}, "last_serial": 9874214, "releases": {"1.1.23": [{"comment_text": "", "digests": {"md5": "211333725841aa1115ebb6fa7683180d", "sha256": "927887539d25ad481b6247ab6a3f97c4ca78737b9d8a5e51c187bf95c18a47d5"}, "downloads": -1, "filename": "configshell-fb-1.1.23.tar.gz", "has_sig": false, "md5_digest": "211333725841aa1115ebb6fa7683180d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 56112, "upload_time": "2017-07-20T15:20:28", "upload_time_iso_8601": "2017-07-20T15:20:28.623497Z", "url": "https://files.pythonhosted.org/packages/81/a0/4adf097a532be9320dbbcbe7020c843cebdc32c084da110753b1bd211d5f/configshell-fb-1.1.23.tar.gz", "yanked": false, "yanked_reason": null}], "1.1.24": [{"comment_text": "", "digests": {"md5": "48cc6b3f1803d8fe68495e865a916203", "sha256": "40580b2e319d9aa0f83eb9e717ccd03601b74a358dd153d9e784d99014f6044c"}, "downloads": -1, "filename": "configshell-fb-1.1.24.tar.gz", "has_sig": false, "md5_digest": "48cc6b3f1803d8fe68495e865a916203", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 56946, "upload_time": "2018-02-12T06:07:46", "upload_time_iso_8601": "2018-02-12T06:07:46.992293Z", "url": "https://files.pythonhosted.org/packages/94/cc/27eb9499bd3500944308675956ea1e0efaa7d34d09d50c8fd271940101ef/configshell-fb-1.1.24.tar.gz", "yanked": false, "yanked_reason": null}], "1.1.25": [{"comment_text": "", "digests": {"md5": "2f6144239be10561bf95fae54ce7981f", "sha256": "4b15eaebfc7809c56fb484033dc5cf13e572faeb34e2ab836d32718ca5d19289"}, "downloads": -1, "filename": "configshell_fb-1.1.25-py3-none-any.whl", "has_sig": false, "md5_digest": "2f6144239be10561bf95fae54ce7981f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 67316, "upload_time": "2019-03-08T11:36:50", "upload_time_iso_8601": "2019-03-08T11:36:50.658859Z", "url": "https://files.pythonhosted.org/packages/81/0f/8fec4114fed110aed20ffdcc9e60e60b10d39f5e529b7bd60e2bf873de3f/configshell_fb-1.1.25-py3-none-any.whl", "yanked": false, "yanked_reason": null}, {"comment_text": "", "digests": {"md5": "86ff2a375d9de39ed9034f1ebc271f07", "sha256": "a5113ca30de7b3dfb9dd060b486d235d3f3a0bb160fdb28178d4300023158e62"}, "downloads": -1, "filename": "configshell-fb-1.1.25.tar.gz", "has_sig": false, "md5_digest": "86ff2a375d9de39ed9034f1ebc271f07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 56900, "upload_time": "2019-03-08T11:36:52", "upload_time_iso_8601": "2019-03-08T11:36:52.176941Z", "url": "https://files.pythonhosted.org/packages/43/a8/99d55db77da9cfa8732ce3ef3a3c79db35f49dc0dd48100f7be58b7a6361/configshell-fb-1.1.25.tar.gz", "yanked": false, "yanked_reason": null}], "1.1.27": [{"comment_text": "", "digests": {"md5": "2c5c76a50892d05b0f4ab25ee121439c", "sha256": "2a16fb535637452b2dad71800c848b4faa7742ffd1fe671210773a66e7a5ba3c"}, "downloads": -1, "filename": "configshell-fb-1.1.27.tar.gz", "has_sig": false, "md5_digest": "2c5c76a50892d05b0f4ab25ee121439c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 57174, "upload_time": "2019-11-06T12:54:37", "upload_time_iso_8601": "2019-11-06T12:54:37.934229Z", "url": "https://files.pythonhosted.org/packages/c1/b6/86599b430f70b4c8a77e47188fa0bcecca62ecd2900e1011ff37107dc18e/configshell-fb-1.1.27.tar.gz", "yanked": false, "yanked_reason": null}], "1.1.28": [{"comment_text": "", "digests": {"md5": "effc6c44784e5cd77e2eacd07bef494d", "sha256": "e471129ea267c554afaf5caf27821d1e9139ed2df32fb4e4d66a1a1704493210"}, "downloads": -1, "filename": "configshell-fb-1.1.28.tar.gz", "has_sig": false, "md5_digest": "effc6c44784e5cd77e2eacd07bef494d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55076, "upload_time": "2020-05-12T14:13:49", "upload_time_iso_8601": "2020-05-12T14:13:49.827202Z", "url": "https://files.pythonhosted.org/packages/d2/6b/4a9d00d5e08b3f1ef3797b7e36b482389143d2ac530ee3553dead3c0a18f/configshell-fb-1.1.28.tar.gz", "yanked": false, "yanked_reason": null}], "1.1.29": [{"comment_text": "", "digests": {"md5": "cb0661ec4a787f46013270f834ab79c8", "sha256": "e199aa935fb808114e21d335db6ac2ac3843244d49bc0269c1ff22d0ab107158"}, "downloads": -1, "filename": "configshell-fb-1.1.29.tar.gz", "has_sig": false, "md5_digest": "cb0661ec4a787f46013270f834ab79c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55036, "upload_time": "2021-03-25T07:43:17", "upload_time_iso_8601": "2021-03-25T07:43:17.700193Z", "url": "https://files.pythonhosted.org/packages/24/c6/4b2400d1872bda4309f552cb293d1937eda3e7bf3c0cf38e43eb7b4a41d9/configshell-fb-1.1.29.tar.gz", "yanked": false, "yanked_reason": null}]}, "urls": [{"comment_text": "", "digests": {"md5": "cb0661ec4a787f46013270f834ab79c8", "sha256": "e199aa935fb808114e21d335db6ac2ac3843244d49bc0269c1ff22d0ab107158"}, "downloads": -1, "filename": "configshell-fb-1.1.29.tar.gz", "has_sig": false, "md5_digest": "cb0661ec4a787f46013270f834ab79c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55036, "upload_time": "2021-03-25T07:43:17", "upload_time_iso_8601": "2021-03-25T07:43:17.700193Z", "url": "https://files.pythonhosted.org/packages/24/c6/4b2400d1872bda4309f552cb293d1937eda3e7bf3c0cf38e43eb7b4a41d9/configshell-fb-1.1.29.tar.gz", "yanked": false, "yanked_reason": null}], "vulnerabilities": []}"""


@pytest.fixture
def mock_pypi_response(mocker):
mocker.patch(
"src.pip2spack.core.pypi_package.PyPiPackage._download_missing_information",
return_value=json.loads(PYPI_CONFIGSHELL_FB_MOCK),
)


class TestPyPiPackage:
def test_pypi_package(self, mock_pypi_response):
pypi_package = PyPiPackage("configshell-fb")
assert (
pypi_package.url
== "https://pypi.io/packages/source/c/configshell-fb/configshell-fb-1.1.29.tar.gz"
)

0 comments on commit a9702f1

Please sign in to comment.