From ec8d02b805b665e250bf5d387d6ff618089d27c6 Mon Sep 17 00:00:00 2001 From: Grant Gainey Date: Thu, 20 Feb 2025 11:48:40 -0500 Subject: [PATCH] Bump pulpcore upper bounds to 3.85 Adjusting a number of tests to the stricter pydantic requirements. --- .../tests/functional/api/test_crud_packages.py | 6 +++--- .../tests/functional/api/test_crud_remotes.py | 7 +++---- .../functional/api/test_duplicate_packages.py | 18 +++++++++++------- pulp_deb/tests/functional/api/test_rbac.py | 2 +- .../functional/api/test_source_package.py | 8 ++++---- pulp_deb/tests/functional/api/test_sync.py | 2 +- pyproject.toml | 4 ++-- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/pulp_deb/tests/functional/api/test_crud_packages.py b/pulp_deb/tests/functional/api/test_crud_packages.py index 4585996e2..79852b043 100644 --- a/pulp_deb/tests/functional/api/test_crud_packages.py +++ b/pulp_deb/tests/functional/api/test_crud_packages.py @@ -13,7 +13,7 @@ def test_create_package(apt_package_api, deb_package_factory): # Create a package and verify its attributes attrs = { "relative_path": DEB_PACKAGE_RELPATH, - "file": get_local_package_absolute_path(DEB_PACKAGE_RELPATH), + "file": str(get_local_package_absolute_path(DEB_PACKAGE_RELPATH)), } package = deb_package_factory(**attrs) assert package.relative_path == DEB_PACKAGE_RELPATH @@ -47,7 +47,7 @@ def test_same_sha256_same_relative_path_no_repo( ): """Test whether uploading the same package works and that it stays unique.""" attrs = { - "file": get_local_package_absolute_path(DEB_PACKAGE_RELPATH), + "file": str(get_local_package_absolute_path(DEB_PACKAGE_RELPATH)), "relative_path": DEB_PACKAGE_RELPATH, } @@ -74,7 +74,7 @@ def test_structured_package_upload( ): """Test whether uploading a structured package works and creates the correct paths.""" attrs = { - "file": get_local_package_absolute_path(DEB_PACKAGE_RELPATH), + "file": str(get_local_package_absolute_path(DEB_PACKAGE_RELPATH)), "relative_path": DEB_PACKAGE_RELPATH, "distribution": str(uuid4()), "component": str(uuid4()), diff --git a/pulp_deb/tests/functional/api/test_crud_remotes.py b/pulp_deb/tests/functional/api/test_crud_remotes.py index 3373ee169..ef8765dc4 100644 --- a/pulp_deb/tests/functional/api/test_crud_remotes.py +++ b/pulp_deb/tests/functional/api/test_crud_remotes.py @@ -60,8 +60,8 @@ def test_create_remote_repository_with_same_name( @pytest.mark.parallel def test_create_remote_repository_without_url(deb_remote_custom_data_factory): """Verify whether it is possible to create a remote without an URL.""" + pytest.skip("pydantic catches this before we get to the server") data = gen_deb_remote_verbose() - with pytest.raises(ApiException) as exc: deb_remote_custom_data_factory(data) @@ -154,10 +154,9 @@ def test_remote_download_policies( # Create a snapshot of the remote for later reference remote_snapshot = deb_get_remote_by_href(remote.pulp_href) - # Attempt to change the remote policy to an invalid string - with pytest.raises(ApiException) as exc: + # Attempt to change the remote policy to an invalid string (now caught by pydantic) + with pytest.raises(Exception): deb_patch_remote(remote, {"policy": str(uuid4())}) - assert exc.value.status == 400 # Verify that the remote policy remains unchanged remote = deb_get_remote_by_href(remote.pulp_href) diff --git a/pulp_deb/tests/functional/api/test_duplicate_packages.py b/pulp_deb/tests/functional/api/test_duplicate_packages.py index f0832f2ae..ea0fba8d6 100644 --- a/pulp_deb/tests/functional/api/test_duplicate_packages.py +++ b/pulp_deb/tests/functional/api/test_duplicate_packages.py @@ -43,7 +43,7 @@ def test_upload_package_and_duplicate( # Upload a test package to a component in the repo. package_upload_params = { - "file": get_local_package_absolute_path(DEB_PACKAGE_RELPATH), + "file": str(get_local_package_absolute_path(DEB_PACKAGE_RELPATH)), "relative_path": DEB_PACKAGE_RELPATH, "distribution": str(uuid4()), "component": str(uuid4()), @@ -70,8 +70,10 @@ def test_upload_package_and_duplicate( ) # Upload a duplicate of the first package into the repo. - package_upload_params["file"] = get_local_package_absolute_path( - package_name=DEB_PACKAGE_RELPATH, relative_path=DUPLICATE_PACKAGE_DIR + package_upload_params["file"] = str( + get_local_package_absolute_path( + package_name=DEB_PACKAGE_RELPATH, relative_path=DUPLICATE_PACKAGE_DIR + ) ) deb_package_factory(**package_upload_params) @@ -110,13 +112,15 @@ def test_add_duplicates_to_repo( """ # Upload two duplicate packages. package_upload_params = { - "file": get_local_package_absolute_path( - package_name=DEB_PACKAGE_RELPATH, relative_path=DUPLICATE_PACKAGE_DIR + "file": str( + get_local_package_absolute_path( + package_name=DEB_PACKAGE_RELPATH, relative_path=DUPLICATE_PACKAGE_DIR + ) ), "relative_path": DEB_PACKAGE_RELPATH, } href1 = deb_package_factory(**package_upload_params).pulp_href - package_upload_params["file"] = get_local_package_absolute_path(DEB_PACKAGE_RELPATH) + package_upload_params["file"] = str(get_local_package_absolute_path(DEB_PACKAGE_RELPATH)) href2 = deb_package_factory(**package_upload_params).pulp_href # Generate an empty test repo. @@ -129,5 +133,5 @@ def test_add_duplicates_to_repo( # Assert the error message. assert "Cannot create repository version since there are newly added packages with" in str( - exception.value + exception.value.task.error["description"] ) diff --git a/pulp_deb/tests/functional/api/test_rbac.py b/pulp_deb/tests/functional/api/test_rbac.py index 69fff540b..d015ba030 100644 --- a/pulp_deb/tests/functional/api/test_rbac.py +++ b/pulp_deb/tests/functional/api/test_rbac.py @@ -42,7 +42,7 @@ def test_rbac_upload(deb_repository_factory, deb_package_factory, gen_user): user_denied = gen_user() repo = deb_repository_factory() package_attrs = { - "file": get_local_package_absolute_path(DEB_PACKAGE_RELPATH), + "file": str(get_local_package_absolute_path(DEB_PACKAGE_RELPATH)), "relative_path": DEB_PACKAGE_RELPATH, "repository": repo.pulp_href, } diff --git a/pulp_deb/tests/functional/api/test_source_package.py b/pulp_deb/tests/functional/api/test_source_package.py index 26ecada28..1d5d57ac5 100644 --- a/pulp_deb/tests/functional/api/test_source_package.py +++ b/pulp_deb/tests/functional/api/test_source_package.py @@ -42,7 +42,7 @@ def artifact_factory( def _artifact_factory(relative_name, relative_path=SOURCE_PACKAGE_PATH): try: file = get_local_package_absolute_path(relative_name, relative_path=relative_path) - artifact = gen_object_with_cleanup(pulpcore_bindings.ArtifactsApi, file) + artifact = gen_object_with_cleanup(pulpcore_bindings.ArtifactsApi, str(file)) except ApiException as exc: if artifact := _find_existing_artifact(pulpcore_bindings.ArtifactsApi, exc): return artifact @@ -84,13 +84,13 @@ def test_upload_source_package_and_publish( source_package = source_packages.results[0] else: # source package doesn't exist - artifact_factory(SOURCE_PACKAGE_SOURCE) - artifact = artifact_factory(SOURCE_PACKAGE_RELPATH) + artifact_factory(str(SOURCE_PACKAGE_SOURCE)) + artifact = artifact_factory(str(SOURCE_PACKAGE_RELPATH)) # Upload a test source package package_upload_params = { "artifact": artifact.pulp_href, - "relative_path": SOURCE_PACKAGE_RELPATH, + "relative_path": str(SOURCE_PACKAGE_RELPATH), } source_package = deb_source_package_factory(**package_upload_params) deb_modify_repository(repository, {"add_content_units": [source_package.pulp_href]}) diff --git a/pulp_deb/tests/functional/api/test_sync.py b/pulp_deb/tests/functional/api/test_sync.py index ffa52013e..f97ae9c98 100644 --- a/pulp_deb/tests/functional/api/test_sync.py +++ b/pulp_deb/tests/functional/api/test_sync.py @@ -162,7 +162,7 @@ def test_sync_invalid_cases( with pytest.raises(PulpTaskError) as exc: deb_sync_repository(remote, repo) for exp in expected: - assert exp in str(exc.value) + assert exp in str(exc.value.task.error["description"]) @pytest.mark.parallel diff --git a/pyproject.toml b/pyproject.toml index a9c0e610a..6bf7894da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ requires-python = ">=3.9" dependencies = [ # All things django and asyncio are deliberately left to pulpcore # Example transitive requirements: asgiref, asyncio, aiohttp - "pulpcore>=3.49.0,<3.70", + "pulpcore>=3.49.0,<3.85", "python-debian>=0.1.44,<0.2.0", "python-gnupg>=0.5,<0.6", "jsonschema>=4.6,<5.0", @@ -165,4 +165,4 @@ replace = "version = \"{new_version}\"" filename = "./pyproject.toml" search = "version = \"{current_version}\"" -replace = "version = \"{new_version}\"" \ No newline at end of file +replace = "version = \"{new_version}\""