Skip to content

Commit cbaa757

Browse files
authored
Merge pull request #896 from jobselko/patchback/backports/3.10/a37d040b901d70a527c208fab9edef486039a205/pr-692
[PR #692/a37d040b backport][3.10] Fix package_types filter breaking others
2 parents 908d3bc + 291eaa6 commit cbaa757

File tree

5 files changed

+78
-1
lines changed

5 files changed

+78
-1
lines changed

CHANGES/691.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the `package_types` filter breaking other remote filters.

pulp_python/app/tasks/sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def create_bandersnatch_config(remote):
8282
config["plugins"]["enabled"] += "prerelease_release\n"
8383
if remote.package_types:
8484
rrfm = "regex_release_file_metadata"
85-
config["plugins"]["enabled"] += rrfm
85+
config["plugins"]["enabled"] += f"{rrfm}\n"
8686
if not config.has_section(rrfm):
8787
config.add_section(rrfm)
8888
config[rrfm]["any:release_file.packagetype"] = "\n".join(remote.package_types)

pulp_python/tests/functional/api/test_sync.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,23 @@ def test_no_platform_sync(self):
641641
)
642642

643643

644+
@pytest.mark.parallel
645+
def test_sync_multiple_filters(
646+
python_repo_with_sync, python_remote_factory, python_content_summary
647+
):
648+
"""Tests sync with multiple filters."""
649+
remote = python_remote_factory(
650+
includes=PYTHON_LG_PROJECT_SPECIFIER,
651+
package_types=["bdist_wheel"],
652+
keep_latest_packages=1,
653+
prereleases=False
654+
)
655+
repo = python_repo_with_sync(remote)
656+
657+
summary = python_content_summary(repository_version=repo.latest_version_href)
658+
assert summary.present["python.python"]["count"] == PYTHON_LG_FIXTURE_COUNTS["multi"]
659+
660+
644661
@pytest.mark.parallel
645662
def test_proxy_sync(
646663
python_repo,

pulp_python/tests/functional/conftest.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import uuid
23

34
from pulp_smash.pulp3.utils import gen_distribution, gen_repo
45
from pulp_python.tests.functional.utils import gen_python_remote
@@ -9,6 +10,7 @@
910
DistributionsPypiApi,
1011
PublicationsPypiApi,
1112
RepositoriesPythonApi,
13+
RepositoriesPythonVersionsApi,
1214
RemotesPythonApi,
1315
)
1416

@@ -29,6 +31,12 @@ def python_repo_api_client(python_bindings_client):
2931
return RepositoriesPythonApi(python_bindings_client)
3032

3133

34+
@pytest.fixture
35+
def python_repo_version_api_client(python_bindings_client):
36+
"""Provides the Python Repository Version API client object."""
37+
return RepositoriesPythonVersionsApi(python_bindings_client)
38+
39+
3240
@pytest.fixture
3341
def python_distro_api_client(python_bindings_client):
3442
"""Provides the Python Distribution API client object."""
@@ -55,6 +63,16 @@ def python_publication_api_client(python_bindings_client):
5563

5664
# Object Generation Fixtures
5765

66+
@pytest.fixture
67+
def python_repo_factory(python_repo_api_client, gen_object_with_cleanup):
68+
"""A factory to generate a Python Repository with auto-cleanup."""
69+
def _gen_python_repo(**kwargs):
70+
kwargs.setdefault("name", str(uuid.uuid4()))
71+
return gen_object_with_cleanup(python_repo_api_client, kwargs)
72+
73+
return _gen_python_repo
74+
75+
5876
@pytest.fixture
5977
def python_repo(python_repo_api_client, gen_object_with_cleanup):
6078
"""Creates a Python Repository and deletes it at test cleanup time."""
@@ -92,3 +110,43 @@ def _gen_python_remote(**kwargs):
92110
return gen_object_with_cleanup(python_remote_api_client, body)
93111

94112
yield _gen_python_remote
113+
114+
115+
@pytest.fixture
116+
def python_repo_with_sync(
117+
python_repo_api_client, python_repo_factory, python_remote_factory, monitor_task
118+
):
119+
"""A factory to generate a Python Repository synced with the passed in Remote."""
120+
def _gen_python_repo_sync(remote=None, mirror=False, repository=None, **body):
121+
kwargs = {}
122+
if pulp_domain := body.get("pulp_domain"):
123+
kwargs["pulp_domain"] = pulp_domain
124+
remote = remote or python_remote_factory(**kwargs)
125+
repo = repository or python_repo_factory(**body)
126+
sync_body = {"mirror": mirror, "remote": remote.pulp_href}
127+
monitor_task(python_repo_api_client.sync(repo.pulp_href, sync_body).task)
128+
return python_repo_api_client.read(repo.pulp_href)
129+
130+
yield _gen_python_repo_sync
131+
132+
133+
@pytest.fixture
134+
def python_content_summary(python_repo_api_client, python_repo_version_api_client):
135+
"""Get a summary of the repository version's content."""
136+
def _gen_summary(repository_version=None, repository=None, version=None):
137+
if repository_version is None:
138+
repo_href = get_href(repository)
139+
if version:
140+
repo_ver_href = f"{repo_href}versions/{version}/"
141+
else:
142+
repo_ver_href = python_repo_api_client.read(repo_href).latest_version_href
143+
else:
144+
repo_ver_href = get_href(repository_version)
145+
return python_repo_version_api_client.read(repo_ver_href).content_summary
146+
147+
yield _gen_summary
148+
149+
150+
def get_href(item):
151+
"""Tries to get the href from the given item, whether it is a string or object."""
152+
return item if isinstance(item, str) else item.pulp_href

pulp_python/tests/functional/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
"latest_3": 37,
156156
"sdist": 24,
157157
"bdist_wheel": 54,
158+
"multi": 26, # keep_latest=1, package_types="bdist_wheel", prereleases=False
158159
}
159160

160161
DJANGO_LATEST_3 = 4 # latest version has 2 dists, each other has 1

0 commit comments

Comments
 (0)