From 843d91c61ad3967a12290aca370658f2f3dd328e Mon Sep 17 00:00:00 2001 From: Francisco Schulz Date: Thu, 13 Oct 2022 11:26:58 +0200 Subject: [PATCH] add pytests to check if a configured bucket can be found --- test/__init__.py | 0 tests/conftest.py | 15 +++++++++++++++ tests/test_storage.py | 5 +++++ 3 files changed, 20 insertions(+) delete mode 100644 test/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/test_storage.py diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..7c80754 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,15 @@ +from distutils.command.config import config +import pytest +from pyinfra.config import get_config +import os + +@pytest.fixture(params=) +def storage_config(request): + if request.param == "s3": + os.environ["STORAGE_BACKEND"] = "s3" + os.environ["STORAGE_BUCKET_NAME"] = "pyinfra-test-bucket" + else: + os.environ["STORAGE_BACKEND"] = "aks" + os.environ["STORAGE_AZURECONTAINERNAME"] = "pyinfra-test-bucket" + + return get_config() diff --git a/tests/test_storage.py b/tests/test_storage.py new file mode 100644 index 0000000..830f9df --- /dev/null +++ b/tests/test_storage.py @@ -0,0 +1,5 @@ +from pyinfra.storage import get_storage + +def test_storage(storage_config) -> None: + storage = get_storage(storage_config) + assert storage.has_bucket(storage_config.storage_bucket)