Skip to content

Commit 0bc6d35

Browse files
committed
Raise upperbound for pkginfo requirement
1 parent 40c7af9 commit 0bc6d35

File tree

4 files changed

+88
-51
lines changed

4 files changed

+88
-51
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure uploading packages with metadata spec 2.4 is supported.

pulp_python/tests/functional/api/test_crud_content_unit.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,16 @@ def test_upload_metadata_23_spec(python_content_factory):
242242
content = python_content_factory(filename, url=package.url)
243243
assert content.metadata_version == "2.3"
244244
break
245+
246+
247+
@pytest.mark.parallel
248+
def test_upload_metadata_24_spec(python_content_factory):
249+
"""Test that packages using metadata spec 2.4 can be uploaded to pulp."""
250+
filename = "urllib3-2.3.0-py3-none-any.whl"
251+
with PyPISimple() as client:
252+
page = client.get_project_page("urllib3")
253+
for package in page.packages:
254+
if package.filename == filename:
255+
content = python_content_factory(filename, url=package.url)
256+
assert content.metadata_version == "2.4"
257+
break

pulp_python/tests/functional/api/test_pypi_apis.py

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import requests
44
import subprocess
55
import tempfile
6+
import pytest
67

78
from urllib.parse import urljoin
89

9-
from pulp_smash.pulp3.bindings import monitor_task, tasks as task_api
10+
from pulp_smash.pulp3.bindings import monitor_task
1011
from pulp_smash.pulp3.utils import get_added_content_summary, get_content_summary
1112
from pulp_python.tests.functional.constants import (
1213
PYTHON_CONTENT_NAME,
@@ -40,6 +41,19 @@
4041
PYPI_HOST = urljoin(HOST, PULP_PYPI_BASE_URL)
4142

4243

44+
@pytest.fixture(scope="module")
45+
def python_package_dist_directory(tmp_path_factory, http_get):
46+
"""Creates a temp dir to hold package distros for uploading."""
47+
dist_dir = tmp_path_factory.mktemp("dist")
48+
egg_file = dist_dir / PYTHON_EGG_FILENAME
49+
wheel_file = dist_dir / PYTHON_WHEEL_FILENAME
50+
with open(egg_file, "wb") as f:
51+
f.write(http_get(PYTHON_EGG_URL))
52+
with open(wheel_file, "wb") as f:
53+
f.write(http_get(PYTHON_WHEEL_URL))
54+
yield dist_dir, egg_file, wheel_file
55+
56+
4357
class PyPISummaryTestCase(TestCaseUsingBindings, TestHelpersMixin):
4458
"""Tests the summary response of the base url of an index."""
4559

@@ -162,18 +176,51 @@ def test_package_upload_simple(self):
162176
content = get_added_content_summary(repo, f"{repo.versions_href}1/")
163177
self.assertDictEqual({PYTHON_CONTENT_NAME: 1}, content)
164178

165-
def test_twine_upload(self):
166-
"""Tests that packages can be properly uploaded through Twine."""
167-
repo, distro = self._create_empty_repo_and_distribution()
168-
url = urljoin(PYPI_HOST, distro.base_path + "/legacy/")
169-
username, password = "admin", "password"
179+
180+
@pytest.mark.parallel
181+
def test_twine_upload(
182+
pulpcore_bindings,
183+
python_content_summary,
184+
python_empty_repo_distro,
185+
python_package_dist_directory,
186+
monitor_task,
187+
):
188+
"""Tests that packages can be properly uploaded through Twine."""
189+
repo, distro = python_empty_repo_distro()
190+
url = urljoin(distro.base_url, "legacy/")
191+
dist_dir, _, _ = python_package_dist_directory
192+
username, password = "admin", "password"
193+
subprocess.run(
194+
(
195+
"twine",
196+
"upload",
197+
"--repository-url",
198+
url,
199+
dist_dir / "*",
200+
"-u",
201+
username,
202+
"-p",
203+
password,
204+
),
205+
capture_output=True,
206+
check=True,
207+
)
208+
tasks = pulpcore_bindings.TasksApi.list(reserved_resources=repo.pulp_href).results
209+
for task in reversed(tasks):
210+
t = monitor_task(task.pulp_href)
211+
repo_ver_href = t.created_resources[-1]
212+
summary = python_content_summary(repository_version=repo_ver_href)
213+
assert summary.present["python.python"]["count"] == 2
214+
215+
# Test re-uploading same packages gives error
216+
with pytest.raises(subprocess.CalledProcessError):
170217
subprocess.run(
171218
(
172219
"twine",
173220
"upload",
174221
"--repository-url",
175222
url,
176-
self.dists_dir.name + "/*",
223+
dist_dir / "*",
177224
"-u",
178225
username,
179226
"-p",
@@ -182,50 +229,26 @@ def test_twine_upload(self):
182229
capture_output=True,
183230
check=True,
184231
)
185-
tasks = task_api.list(reserved_resources_record=[repo.pulp_href]).results
186-
for task in reversed(tasks):
187-
t = monitor_task(task.pulp_href)
188-
repo_ver_href = t.created_resources[-1]
189-
content = get_content_summary(repo, f"{repo_ver_href}")
190-
self.assertDictEqual({PYTHON_CONTENT_NAME: 2}, content)
191-
192-
# Test re-uploading same packages gives error
193-
with self.assertRaises(subprocess.CalledProcessError):
194-
subprocess.run(
195-
(
196-
"twine",
197-
"upload",
198-
"--repository-url",
199-
url,
200-
self.dists_dir.name + "/*",
201-
"-u",
202-
username,
203-
"-p",
204-
password,
205-
),
206-
capture_output=True,
207-
check=True,
208-
)
209232

210-
# Test re-uploading same packages with --skip-existing works
211-
output = subprocess.run(
212-
(
213-
"twine",
214-
"upload",
215-
"--repository-url",
216-
url,
217-
self.dists_dir.name + "/*",
218-
"-u",
219-
username,
220-
"-p",
221-
password,
222-
"--skip-existing",
223-
),
224-
capture_output=True,
225-
check=True,
226-
text=True
227-
)
228-
self.assertEqual(output.stdout.count("Skipping"), 2)
233+
# Test re-uploading same packages with --skip-existing works
234+
output = subprocess.run(
235+
(
236+
"twine",
237+
"upload",
238+
"--repository-url",
239+
url,
240+
dist_dir / "*",
241+
"-u",
242+
username,
243+
"-p",
244+
password,
245+
"--skip-existing",
246+
),
247+
capture_output=True,
248+
check=True,
249+
text=True
250+
)
251+
assert output.stdout.count("Skipping") == 2
229252

230253

231254
class PyPISimpleApi(TestCaseUsingBindings, TestHelpersMixin):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pulpcore>=3.28,<3.55
2-
pkginfo>=1.10.0,<1.12.0 # Twine has <1.11 in their requirements
2+
pkginfo>=1.12.0,<1.13.0
33
bandersnatch>=6.1,<6.2
44
pypi-simple>=0.9.0,<1.0.0

0 commit comments

Comments
 (0)