diff --git a/pyinfra/config.py b/pyinfra/config.py index 2e5f071..c613a49 100644 --- a/pyinfra/config.py +++ b/pyinfra/config.py @@ -24,6 +24,9 @@ class DotIndexable: def __repr__(self): return self.x.__repr__() + def __getitem__(self, item): + return self.__getattr__(item) + class Config: def __init__(self, config_path): diff --git a/pyinfra/storage/clients/s3.py b/pyinfra/storage/clients/s3.py index 6f1f691..1d66265 100644 --- a/pyinfra/storage/clients/s3.py +++ b/pyinfra/storage/clients/s3.py @@ -7,7 +7,7 @@ from pyinfra.exceptions import InvalidEndpoint def parse_endpoint(endpoint): - endpoint_pattern = r"(?Phttps?)://(?P
(?:(?:(?:\d{1,3}\.){3}\d{1,3})|\w+):\d+)" + endpoint_pattern = r"(?Phttps?)://(?P
(?:(?:(?:\d{1,3}\.){3}\d{1,3})|(?:\w|\.)+)(?:\:\d+)?)" match = re.match(endpoint_pattern, endpoint) diff --git a/pyinfra/test/unit_tests/storage_test.py b/pyinfra/test/unit_tests/storage_test.py index 957e11a..c971574 100644 --- a/pyinfra/test/unit_tests/storage_test.py +++ b/pyinfra/test/unit_tests/storage_test.py @@ -35,26 +35,27 @@ class TestStorage: storage.make_bucket(bucket_name) assert storage.bucket_exists(bucket_name) -def get_adapter(client_name): + +def get_adapter(client_name, s3_backend): if client_name == "mock": return StorageAdapterMock(StorageClientMock()) if client_name == "azure": return AzureStorageAdapter(get_azure_client(CONFIG.test.azure)) if client_name == "s3": - return S3StorageAdapter(get_s3_client(CONFIG.test.minio)) + return S3StorageAdapter(get_s3_client(CONFIG.test[s3_backend])) else: raise UnknownClient(client_name) -@pytest.fixture -def adapter(client_name): - adapter = get_adapter(client_name) - return adapter +# @pytest.mark.parametrize("s3_backend", ["minio", "w"]) +# def adapter(client_name, s3_backend): +# adapter = get_adapter(client_name, s3_backend) +# return adapter -@pytest.fixture -def storage(client_name, bucket_name): - storage = Storage(get_adapter(client_name)) +@pytest.fixture(params=["minio", "aws"]) +def storage(client_name, bucket_name, request): + storage = Storage(get_adapter(client_name, request.param)) storage.make_bucket(bucket_name) storage.clear_bucket(bucket_name) logging.info(client_name)