diff --git a/CHANGES/682.bugfix b/CHANGES/682.bugfix new file mode 100644 index 00000000..4bf3e5b5 --- /dev/null +++ b/CHANGES/682.bugfix @@ -0,0 +1 @@ +Fixed uploads not supporting packages using metadata spec 2.3 diff --git a/pulp_python/tests/functional/api/test_crud_content_unit.py b/pulp_python/tests/functional/api/test_crud_content_unit.py index 2f385f3c..25834bc2 100644 --- a/pulp_python/tests/functional/api/test_crud_content_unit.py +++ b/pulp_python/tests/functional/api/test_crud_content_unit.py @@ -1,5 +1,6 @@ # coding=utf-8 """Tests that perform actions over content unit.""" +import pytest from pulp_smash.pulp3.bindings import delete_orphans, monitor_task, PulpTaskError from pulp_python.tests.functional.utils import ( @@ -12,6 +13,7 @@ from pulp_python.tests.functional.utils import set_up_module as setUpModule # noqa:F401 from tempfile import NamedTemporaryFile from urllib.parse import urljoin +from pypi_simple import PyPISimple from pulp_smash.utils import http_get from pulp_python.tests.functional.constants import ( @@ -227,3 +229,16 @@ def check_package_data(self, content_unit, expected=PYTHON_PACKAGE_DATA): for k, v in expected.items(): with self.subTest(key=k): self.assertEqual(content_unit[k], v) + + +@pytest.mark.parallel +def test_upload_metadata_23_spec(python_content_factory): + """Test that packages using metadata spec 2.3 can be uploaded to pulp.""" + filename = "urllib3-2.2.2-py3-none-any.whl" + with PyPISimple() as client: + page = client.get_project_page("urllib3") + for package in page.packages: + if package.filename == filename: + content = python_content_factory(filename, url=package.url) + assert content.metadata_version == "2.3" + break diff --git a/pulp_python/tests/functional/conftest.py b/pulp_python/tests/functional/conftest.py index 408f46a9..44c2886f 100644 --- a/pulp_python/tests/functional/conftest.py +++ b/pulp_python/tests/functional/conftest.py @@ -2,6 +2,7 @@ import uuid from pulp_smash.pulp3.utils import gen_distribution, gen_repo +from pulp_python.tests.functional.constants import PYTHON_EGG_FILENAME, PYTHON_URL from pulp_python.tests.functional.utils import gen_python_remote from pulpcore.client.pulp_python import ( @@ -130,6 +131,38 @@ def _gen_python_repo_sync(remote=None, mirror=False, repository=None, **body): yield _gen_python_repo_sync +@pytest.fixture +def download_python_file(tmp_path, http_get): + """Download a Python file and return its path.""" + def _download_python_file(relative_path, url): + file_path = tmp_path / relative_path + with open(file_path, mode="wb") as f: + f.write(http_get(url)) + return file_path + + yield _download_python_file + + +@pytest.fixture +def python_content_factory(python_content_api_client, download_python_file, monitor_task): + """A factory to create a Python Package Content.""" + def _gen_python_content(relative_path=PYTHON_EGG_FILENAME, url=None, **body): + body["relative_path"] = relative_path + if url: + body["file"] = download_python_file(relative_path, url) + elif not any(x in body for x in ("artifact", "file", "upload")): + body["file"] = download_python_file(PYTHON_EGG_FILENAME, PYTHON_URL) + if repo := body.get("repository"): + repo_href = repo if isinstance(repo, str) else repo.pulp_href + body["repository"] = repo_href + + task = python_content_api_client.create(**body).task + response = monitor_task(task) + return python_content_api_client.read(response.created_resources[0]) + + yield _gen_python_content + + @pytest.fixture def python_content_summary(python_repo_api_client, python_repo_version_api_client): """Get a summary of the repository version's content.""" diff --git a/requirements.txt b/requirements.txt index f1271e41..17c293c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ pulpcore>=3.28.0,<3.40 -pkginfo>=1.8.2,<1.9.7 +pkginfo>=1.10.0,<1.12.0 # Twine has <1.11 in their requirements bandersnatch>=6.1,<6.2 pypi-simple>=0.9.0,<1.0.0 +# pinned until https://github.com/Azure/Azurite/issues/2562 is resolved +azure-storage-blob<12.26.0