From b444159d089ded5db48009e7e5ab346eb5ecb278 Mon Sep 17 00:00:00 2001 From: Pedro Brochado Date: Wed, 11 Dec 2024 14:26:19 -0300 Subject: [PATCH] fixup: use fixture settings --- .../functional/api/test_artifact_distribution.py | 5 ++--- pulpcore/tests/functional/api/test_crd_artifacts.py | 4 ++-- pulpcore/tests/functional/api/test_crud_domains.py | 3 ++- pulpcore/tests/functional/api/test_status.py | 11 +++++------ .../tests/functional/api/using_plugin/test_orphans.py | 5 ++++- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pulpcore/tests/functional/api/test_artifact_distribution.py b/pulpcore/tests/functional/api/test_artifact_distribution.py index 6ac3706e61b..c9c35dd11e0 100644 --- a/pulpcore/tests/functional/api/test_artifact_distribution.py +++ b/pulpcore/tests/functional/api/test_artifact_distribution.py @@ -2,7 +2,6 @@ import subprocess from hashlib import sha256 -from django.conf import settings OBJECT_STORAGES = ( @@ -12,7 +11,7 @@ ) -def test_artifact_distribution(random_artifact): +def test_artifact_distribution(pulp_settings, random_artifact): artifact_uuid = random_artifact.pulp_href.split("/")[-2] commands = ( @@ -29,7 +28,7 @@ def test_artifact_distribution(random_artifact): hasher = sha256() hasher.update(response.content) assert hasher.hexdigest() == random_artifact.sha256 - if settings.STORAGES["default"]["BACKEND"] in OBJECT_STORAGES: + if pulp_settings.STORAGES["default"]["BACKEND"] in OBJECT_STORAGES: content_disposition = response.headers.get("Content-Disposition") assert content_disposition is not None filename = artifact_uuid diff --git a/pulpcore/tests/functional/api/test_crd_artifacts.py b/pulpcore/tests/functional/api/test_crd_artifacts.py index 26d60a75646..c9ebfedb63f 100644 --- a/pulpcore/tests/functional/api/test_crd_artifacts.py +++ b/pulpcore/tests/functional/api/test_crd_artifacts.py @@ -6,7 +6,6 @@ import uuid import pytest -from django.conf import settings from pulpcore.client.pulpcore import ApiException @@ -145,9 +144,10 @@ def test_upload_mixed_attrs(pulpcore_bindings, pulpcore_random_file): @pytest.mark.parallel -def test_delete_artifact(pulpcore_bindings, pulpcore_random_file, gen_user): +def test_delete_artifact(pulpcore_bindings, pulpcore_random_file, gen_user, pulp_settings): """Verify that the deletion of artifacts is prohibited for both regular users and administrators.""" + settings = pulp_settings if settings.STORAGES["default"]["BACKEND"] != "pulpcore.app.models.storage.FileSystem": pytest.skip("this test only works for filesystem storage") media_root = settings.MEDIA_ROOT diff --git a/pulpcore/tests/functional/api/test_crud_domains.py b/pulpcore/tests/functional/api/test_crud_domains.py index 6fe88f2afec..c7d91d9953b 100644 --- a/pulpcore/tests/functional/api/test_crud_domains.py +++ b/pulpcore/tests/functional/api/test_crud_domains.py @@ -58,8 +58,9 @@ def test_default_domain(pulpcore_bindings): # Read the default domain, ensure storage is set to default default_domain = domains.results[0] + print(settings._wrapped) assert default_domain.name == "default" - assert default_domain.storage_class == settings.storages.default.backend + assert default_domain.storage_class == settings.STORAGES["default"]["BACKEND"] assert default_domain.redirect_to_object_storage == settings.REDIRECT_TO_OBJECT_STORAGE assert default_domain.hide_guarded_distributions == settings.HIDE_GUARDED_DISTRIBUTIONS diff --git a/pulpcore/tests/functional/api/test_status.py b/pulpcore/tests/functional/api/test_status.py index 3d18d0bffb3..8f64f121ecd 100644 --- a/pulpcore/tests/functional/api/test_status.py +++ b/pulpcore/tests/functional/api/test_status.py @@ -2,7 +2,6 @@ import pytest -from django.conf import settings from jsonschema import validate from pulpcore.client.pulpcore import ApiException @@ -59,24 +58,24 @@ @pytest.mark.parallel -def test_get_authenticated(test_path, pulpcore_bindings): +def test_get_authenticated(test_path, pulpcore_bindings, pulp_settings): """GET the status path with valid credentials. Verify the response with :meth:`verify_get_response`. """ response = pulpcore_bindings.StatusApi.status_read() - verify_get_response(response.to_dict(), STATUS) + verify_get_response(response.to_dict(), STATUS, pulp_settings) @pytest.mark.parallel -def test_get_unauthenticated(test_path, pulpcore_bindings, anonymous_user): +def test_get_unauthenticated(test_path, pulpcore_bindings, anonymous_user, pulp_settings): """GET the status path with no credentials. Verify the response with :meth:`verify_get_response`. """ with anonymous_user: response = pulpcore_bindings.StatusApi.status_read() - verify_get_response(response.to_dict(), STATUS) + verify_get_response(response.to_dict(), STATUS, pulp_settings) @pytest.mark.parallel @@ -127,7 +126,7 @@ def test_storage_per_domain( assert default_status.storage != domain_status.storage -def verify_get_response(status, expected_schema): +def verify_get_response(status, expected_schema, settings): """Verify the response to an HTTP GET call. Verify that several attributes and have the correct type or value. diff --git a/pulpcore/tests/functional/api/using_plugin/test_orphans.py b/pulpcore/tests/functional/api/using_plugin/test_orphans.py index 49440ff41fa..f46ee99c5b1 100644 --- a/pulpcore/tests/functional/api/using_plugin/test_orphans.py +++ b/pulpcore/tests/functional/api/using_plugin/test_orphans.py @@ -3,7 +3,6 @@ import os import pytest -from pulpcore.app import settings def test_content_orphan_filter( @@ -68,7 +67,9 @@ def test_orphans_delete( random_artifact, file_random_content_unit, monitor_task, + pulp_settings, ): + settings = pulp_settings # Verify that the system contains the orphan content unit and the orphan artifact. content_unit = file_bindings.ContentFilesApi.read(file_random_content_unit.pulp_href) artifact = pulpcore_bindings.ArtifactsApi.read(random_artifact.pulp_href) @@ -100,7 +101,9 @@ def test_orphans_cleanup( random_artifact, file_random_content_unit, monitor_task, + pulp_settings, ): + settings = pulp_settings # Cleanup orphans with a nonzero orphan_protection_time monitor_task(pulpcore_bindings.OrphansCleanupApi.cleanup({"orphan_protection_time": 10}).task)