From b5aa4dae181259f833928c1e2acdbcdbf54b3bdb Mon Sep 17 00:00:00 2001 From: Lubos Mjachky Date: Mon, 1 Jul 2024 22:56:29 +0200 Subject: [PATCH] Make the plugin compatible with pulpcore v3.55 closes #1681 --- CHANGES/1681.misc | 1 + .../tests/functional/api/test_build_images.py | 6 ++-- .../functional/api/test_pulpimportexport.py | 30 ++++++++----------- .../tests/functional/api/test_sync.py | 6 ++-- pulp_container/tests/functional/conftest.py | 4 +-- requirements.txt | 2 +- 6 files changed, 22 insertions(+), 27 deletions(-) create mode 100644 CHANGES/1681.misc diff --git a/CHANGES/1681.misc b/CHANGES/1681.misc new file mode 100644 index 000000000..a2cd58f26 --- /dev/null +++ b/CHANGES/1681.misc @@ -0,0 +1 @@ +Made the plugin compatible with pulpcore v3.55. diff --git a/pulp_container/tests/functional/api/test_build_images.py b/pulp_container/tests/functional/api/test_build_images.py index 52e154907..9f033eb92 100644 --- a/pulp_container/tests/functional/api/test_build_images.py +++ b/pulp_container/tests/functional/api/test_build_images.py @@ -19,7 +19,7 @@ def containerfile_name(): """A fixture for a basic container file used for building images.""" with NamedTemporaryFile() as containerfile: containerfile.write( - b"""FROM busybox:latest + b"""FROM ghcr.io/pulp/hello-world:latest # Copy a file using COPY statement. Use the relative path specified in the 'artifacts' parameter. COPY foo/bar/example.txt /tmp/inside-image.txt # Print the content of the file when the container starts @@ -30,7 +30,7 @@ def containerfile_name(): def test_build_image( - artifacts_api_client, + pulpcore_bindings, container_repository_api, container_distribution_api, gen_object_with_cleanup, @@ -41,7 +41,7 @@ def test_build_image( with NamedTemporaryFile() as text_file: text_file.write(b"some text") text_file.flush() - artifact = gen_object_with_cleanup(artifacts_api_client, text_file.name) + artifact = gen_object_with_cleanup(pulpcore_bindings.ArtifactsApi, text_file.name) repository = gen_object_with_cleanup( container_repository_api, ContainerContainerRepository(**gen_repo()) diff --git a/pulp_container/tests/functional/api/test_pulpimportexport.py b/pulp_container/tests/functional/api/test_pulpimportexport.py index ba227ad89..7e958663c 100644 --- a/pulp_container/tests/functional/api/test_pulpimportexport.py +++ b/pulp_container/tests/functional/api/test_pulpimportexport.py @@ -28,10 +28,7 @@ def test_import_export_standard( container_repository_api, container_repository_version_api, container_manifest_api, - exporters_pulp_api_client, - exporters_pulp_exports_api_client, - importers_pulp_api_client, - importers_pulp_imports_api_client, + pulpcore_bindings, gen_object_with_cleanup, has_pulp_plugin, ): @@ -48,11 +45,11 @@ def test_import_export_standard( "path": f"/tmp/{uuid.uuid4()}/", "repositories": [repository.pulp_href], } - exporter = gen_object_with_cleanup(exporters_pulp_api_client, body) + exporter = gen_object_with_cleanup(pulpcore_bindings.ExportersPulpApi, body) - export_response = exporters_pulp_exports_api_client.create(exporter.pulp_href, {}) + export_response = pulpcore_bindings.ExportersPulpExportsApi.create(exporter.pulp_href, {}) export_href = monitor_task(export_response.task).created_resources[0] - export = exporters_pulp_exports_api_client.read(export_href) + export = pulpcore_bindings.ExportersPulpExportsApi.read(export_href) # Clean the old repository out monitor_task(container_repository_version_api.delete(repository.latest_version_href).task) @@ -65,14 +62,14 @@ def test_import_export_standard( "name": str(uuid.uuid4()), "repo_mapping": {repository.name: import_repository.name}, } - importer = gen_object_with_cleanup(importers_pulp_api_client, body) + importer = gen_object_with_cleanup(pulpcore_bindings.ImportersPulpApi, body) if has_pulp_plugin("core", min="3.36.0"): filenames = [f for f in list(export.output_file_info.keys()) if f.endswith(".tar")] else: filenames = [f for f in list(export.output_file_info.keys()) if f.endswith("tar.gz")] - import_response = importers_pulp_imports_api_client.create( + import_response = pulpcore_bindings.ImportersPulpImportsApi.create( importer.pulp_href, {"path": filenames[0]} ) if hasattr(import_response, "task_group"): @@ -111,10 +108,7 @@ def test_import_export_create_repositories( container_repository_api, container_tag_api, container_manifest_api, - exporters_pulp_api_client, - exporters_pulp_exports_api_client, - importers_pulp_api_client, - importers_pulp_imports_api_client, + pulpcore_bindings, gen_object_with_cleanup, has_pulp_plugin, ): @@ -135,24 +129,24 @@ def test_import_export_create_repositories( "path": f"/tmp/{uuid.uuid4()}/", "repositories": [distribution.repository], } - exporter = gen_object_with_cleanup(exporters_pulp_api_client, body) - export_response = exporters_pulp_exports_api_client.create(exporter.pulp_href, {}) + exporter = gen_object_with_cleanup(pulpcore_bindings.ExportersPulpApi, body) + export_response = pulpcore_bindings.ExportersPulpExportsApi.create(exporter.pulp_href, {}) export_href = monitor_task(export_response.task).created_resources[0] - export = exporters_pulp_exports_api_client.read(export_href) + export = pulpcore_bindings.ExportersPulpExportsApi.read(export_href) # Clean the old repository out monitor_task(container_distribution_api.delete(distribution.pulp_href).task) delete_orphans() body = {"name": str(uuid.uuid4())} - importer = gen_object_with_cleanup(importers_pulp_api_client, body) + importer = gen_object_with_cleanup(pulpcore_bindings.ImportersPulpApi, body) if has_pulp_plugin("core", min="3.36.0"): filenames = [f for f in list(export.output_file_info.keys()) if f.endswith(".tar")] else: filenames = [f for f in list(export.output_file_info.keys()) if f.endswith("tar.gz")] - import_response = importers_pulp_imports_api_client.create( + import_response = pulpcore_bindings.ImportersPulpImportsApi.create( importer.pulp_href, {"path": filenames[0], "create_repositories": True} ) if hasattr(import_response, "task_group"): diff --git a/pulp_container/tests/functional/api/test_sync.py b/pulp_container/tests/functional/api/test_sync.py index 866a2805e..77257348f 100644 --- a/pulp_container/tests/functional/api/test_sync.py +++ b/pulp_container/tests/functional/api/test_sync.py @@ -1,7 +1,7 @@ """Tests that sync container plugin repositories.""" import pytest -from pulpcore.tests.functional import PulpTaskError +from pulpcore.tests.functional.utils import PulpTaskError from pulp_container.tests.functional.constants import PULP_FIXTURE_1, PULP_LABELED_FIXTURE @@ -87,11 +87,11 @@ def test_sync_reclaim_resync( container_remote, container_sync, monitor_task, - repositories_reclaim_space_api_client, + pulpcore_bindings, ): """Check if re-syncing the content after the reclamation ends with no error.""" container_sync(container_repo, container_remote) - monitor_task(repositories_reclaim_space_api_client.reclaim({"repo_hrefs": ["*"]}).task) + monitor_task(pulpcore_bindings.RepositoriesReclaimSpaceApi.reclaim({"repo_hrefs": ["*"]}).task) container_sync(container_repo, container_remote) diff --git a/pulp_container/tests/functional/conftest.py b/pulp_container/tests/functional/conftest.py index 457e443f7..9a56335f7 100644 --- a/pulp_container/tests/functional/conftest.py +++ b/pulp_container/tests/functional/conftest.py @@ -259,9 +259,9 @@ def signing_script_filename(signing_gpg_homedir_path): @pytest.fixture def container_signing_service( + pulpcore_bindings, signing_gpg_metadata, signing_script_filename, - signing_service_api_client, ): """A fixture for a signing service.""" st = os.stat(signing_script_filename) @@ -284,7 +284,7 @@ def container_signing_service( subprocess.check_output(cmd) - signing_service = signing_service_api_client.list(name=service_name).results[0] + signing_service = pulpcore_bindings.SigningServicesApi.list(name=service_name).results[0] assert signing_service.pubkey_fingerprint == fingerprint assert signing_service.public_key == gpg.export_keys(keyid) diff --git a/requirements.txt b/requirements.txt index f3e149f1c..df4182125 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ jsonschema>=4.4,<4.23 -pulpcore>=3.49.0,<3.55 +pulpcore>=3.49.0,<3.70 pyjwt[crypto]>=2.4,<2.9