Skip to content

Commit 370b2a0

Browse files
gerrod3jobselko
authored andcommitted
Fix upload not supporting package metadata 2.3
fixes: #682 (cherry picked from commit 781b976)
1 parent a5b9256 commit 370b2a0

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

CHANGES/682.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed uploads not supporting packages using metadata spec 2.3

pulp_python/tests/functional/api/test_crud_content_unit.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# coding=utf-8
22
"""Tests that perform actions over content unit."""
3+
import pytest
34
from pulp_smash.pulp3.bindings import delete_orphans, monitor_task, PulpTaskError
45

56
from pulp_python.tests.functional.utils import (
@@ -12,6 +13,7 @@
1213
from pulp_python.tests.functional.utils import set_up_module as setUpModule # noqa:F401
1314
from tempfile import NamedTemporaryFile
1415
from urllib.parse import urljoin
16+
from pypi_simple import PyPISimple
1517

1618
from pulp_smash.utils import http_get
1719
from pulp_python.tests.functional.constants import (
@@ -227,3 +229,16 @@ def check_package_data(self, content_unit, expected=PYTHON_PACKAGE_DATA):
227229
for k, v in expected.items():
228230
with self.subTest(key=k):
229231
self.assertEqual(content_unit[k], v)
232+
233+
234+
@pytest.mark.parallel
235+
def test_upload_metadata_23_spec(python_content_factory):
236+
"""Test that packages using metadata spec 2.3 can be uploaded to pulp."""
237+
filename = "urllib3-2.2.2-py3-none-any.whl"
238+
with PyPISimple() as client:
239+
page = client.get_project_page("urllib3")
240+
for package in page.packages:
241+
if package.filename == filename:
242+
content = python_content_factory(filename, url=package.url)
243+
assert content.metadata_version == "2.3"
244+
break

pulp_python/tests/functional/conftest.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import uuid
33

44
from pulp_smash.pulp3.utils import gen_distribution, gen_repo
5+
from pulp_python.tests.functional.constants import PYTHON_EGG_FILENAME, PYTHON_URL
56
from pulp_python.tests.functional.utils import gen_python_remote
67

78
from pulpcore.client.pulp_python import (
@@ -130,6 +131,38 @@ def _gen_python_repo_sync(remote=None, mirror=False, repository=None, **body):
130131
yield _gen_python_repo_sync
131132

132133

134+
@pytest.fixture
135+
def download_python_file(tmp_path, http_get):
136+
"""Download a Python file and return its path."""
137+
def _download_python_file(relative_path, url):
138+
file_path = tmp_path / relative_path
139+
with open(file_path, mode="wb") as f:
140+
f.write(http_get(url))
141+
return file_path
142+
143+
yield _download_python_file
144+
145+
146+
@pytest.fixture
147+
def python_content_factory(python_content_api_client, download_python_file, monitor_task):
148+
"""A factory to create a Python Package Content."""
149+
def _gen_python_content(relative_path=PYTHON_EGG_FILENAME, url=None, **body):
150+
body["relative_path"] = relative_path
151+
if url:
152+
body["file"] = download_python_file(relative_path, url)
153+
elif not any(x in body for x in ("artifact", "file", "upload")):
154+
body["file"] = download_python_file(PYTHON_EGG_FILENAME, PYTHON_URL)
155+
if repo := body.get("repository"):
156+
repo_href = repo if isinstance(repo, str) else repo.pulp_href
157+
body["repository"] = repo_href
158+
159+
task = python_content_api_client.create(**body).task
160+
response = monitor_task(task)
161+
return python_content_api_client.read(response.created_resources[0])
162+
163+
yield _gen_python_content
164+
165+
133166
@pytest.fixture
134167
def python_content_summary(python_repo_api_client, python_repo_version_api_client):
135168
"""Get a summary of the repository version's content."""

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
pulpcore>=3.28.0,<3.40
2-
pkginfo>=1.8.2,<1.9.7
2+
pkginfo>=1.10.0,<1.12.0 # Twine has <1.11 in their requirements
33
bandersnatch>=6.1,<6.2
44
pypi-simple>=0.9.0,<1.0.0
5+
# pinned until https://github.com/Azure/Azurite/issues/2562 is resolved
6+
azure-storage-blob<12.26.0

0 commit comments

Comments
 (0)