From a7ffaeb18fe7e17591cb9d72a7145161bbc96f38 Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Mon, 23 May 2022 10:19:02 +0200 Subject: [PATCH] changed return value of file name listing function for storages to return strings of filenames rather than tuples of bucket name and file name --- pyinfra/storage/adapters/azure.py | 2 +- pyinfra/storage/adapters/s3.py | 2 +- test/storage/client_mock.py | 5 +---- test/unit_tests/storage_test.py | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pyinfra/storage/adapters/azure.py b/pyinfra/storage/adapters/azure.py index 2b96d58..9f908d8 100644 --- a/pyinfra/storage/adapters/azure.py +++ b/pyinfra/storage/adapters/azure.py @@ -62,4 +62,4 @@ class AzureStorageAdapter(StorageAdapter): def get_all_object_names(self, bucket_name): container_client = self.__provide_container_client(bucket_name) blobs = container_client.list_blobs() - return zip(repeat(bucket_name), map(attrgetter("name"), blobs)) + return map(attrgetter("name"), blobs) diff --git a/pyinfra/storage/adapters/s3.py b/pyinfra/storage/adapters/s3.py index df41111..1a67269 100644 --- a/pyinfra/storage/adapters/s3.py +++ b/pyinfra/storage/adapters/s3.py @@ -52,4 +52,4 @@ class S3StorageAdapter(StorageAdapter): def get_all_object_names(self, bucket_name): objs = self.__client.list_objects(bucket_name, recursive=True) - return zip(repeat(bucket_name), map(attrgetter("object_name"), objs)) + return map(attrgetter("object_name"), objs) diff --git a/test/storage/client_mock.py b/test/storage/client_mock.py index c81b02b..9cf53e6 100644 --- a/test/storage/client_mock.py +++ b/test/storage/client_mock.py @@ -1,6 +1,3 @@ -from itertools import repeat - - class StorageClientMock: def __init__(self): self.__data = {} @@ -24,4 +21,4 @@ class StorageClientMock: self.__data[bucket_name] = {} def get_all_object_names(self, bucket_name): - return zip(repeat(bucket_name), self.__data[bucket_name]) + return self.__data[bucket_name] diff --git a/test/unit_tests/storage_test.py b/test/unit_tests/storage_test.py index 14f142c..c1d2aba 100644 --- a/test/unit_tests/storage_test.py +++ b/test/unit_tests/storage_test.py @@ -41,4 +41,4 @@ class TestStorage: storage.put_object(bucket_name, "file1", b"content 1") storage.put_object(bucket_name, "file2", b"content 2") full_names_received = storage.get_all_object_names(bucket_name) - assert {(bucket_name, "file1"), (bucket_name, "file2")} == {*full_names_received} + assert {"file1", "file2"} == {*full_names_received}