From 1f482f24765939dd692d649858548f3c42d6aea0 Mon Sep 17 00:00:00 2001 From: Julius Unverfehrt Date: Tue, 9 Jan 2024 16:07:48 +0100 Subject: [PATCH] fix: storage test --- tests/conftest.py | 6 +++++ .../tests_with_docker_compose/storage_test.py | 25 +++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0cd40d6..35f389c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,9 +2,15 @@ import gzip import json import pytest +from pyinfra.config import get_config from pyinfra.payload_processing.payload import LegacyQueueMessagePayload, QueueMessagePayload +@pytest.fixture(scope="session") +def settings(): + return get_config() + + @pytest.fixture def legacy_payload(x_tenant_id, optional_processing_kwargs): x_tenant_entry = {"X-TENANT-ID": x_tenant_id} if x_tenant_id else {} diff --git a/tests/tests_with_docker_compose/storage_test.py b/tests/tests_with_docker_compose/storage_test.py index 80ab4b0..2a8c0c7 100644 --- a/tests/tests_with_docker_compose/storage_test.py +++ b/tests/tests_with_docker_compose/storage_test.py @@ -1,14 +1,25 @@ -import logging - import pytest -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) +from pyinfra.storage.storage import get_storage_from_config -@pytest.mark.parametrize("storage_backend", ["azure", "s3"], scope="session") -@pytest.mark.parametrize("bucket_name", ["testbucket"], scope="session") -@pytest.mark.parametrize("monitoring_enabled", [False], scope="session") +@pytest.fixture(scope="session") +def storage(storage_backend, bucket_name, settings): + settings.storage_backend = storage_backend + settings.storage_bucket = bucket_name + + storage = get_storage_from_config(settings) + storage.make_bucket(bucket_name) + + yield storage + storage.clear_bucket(bucket_name) + + +# @pytest.mark.parametrize("storage_backend", ["azure", "s3"], scope="session") +# FIXME: Azure storage test needs the secret azure connection string +# when the config is refactored as file, add this and provide file via bitwarden +@pytest.mark.parametrize("storage_backend", ["s3"], scope="session") +@pytest.mark.parametrize("bucket_name", ["bucket"], scope="session") class TestStorage: def test_clearing_bucket_yields_empty_bucket(self, storage, bucket_name): storage.clear_bucket(bucket_name)