Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage][Blob][Batch]Support batch delete empty blob list #13029

Merged
merged 1 commit into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,9 @@ def delete_blobs(self, *blobs, **kwargs):
:dedent: 8
:caption: Deleting multiple blobs.
"""
if len(blobs) == 0:
return iter(list())

reqs, options = self._generate_delete_blobs_options(*blobs, **kwargs)

return self._batch_send(*reqs, **options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,9 @@ async def delete_blobs( # pylint: disable=arguments-differ
:dedent: 12
:caption: Deleting multiple blobs.
"""
if len(blobs) == 0:
return iter(list())

reqs, options = self._generate_delete_blobs_options(*blobs, **kwargs)

return await self._batch_send(*reqs, **options)
Expand Down
7 changes: 6 additions & 1 deletion sdk/storage/azure-storage-blob/tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
PremiumPageBlobTier,
generate_container_sas,
PartialBatchErrorException,
generate_account_sas, ResourceTypes, AccountSasPermissions)
generate_account_sas, ResourceTypes, AccountSasPermissions, ContainerClient)

#------------------------------------------------------------------------------
TEST_CONTAINER_PREFIX = 'container'
Expand Down Expand Up @@ -1048,6 +1048,11 @@ def test_list_blobs_with_delimiter(self, resource_group, location, storage_accou
self.assertNamedItemInContainer(resp, 'b/')
self.assertNamedItemInContainer(resp, 'blob4')

def test_batch_delete_empty_blob_list(self):
container_client = ContainerClient("https://mystorageaccount.blob.core.windows.net", "container")
blob_list = list()
container_client.delete_blobs(*blob_list)

@pytest.mark.skipif(sys.version_info < (3, 0), reason="Batch not supported on Python 2.7")
@GlobalStorageAccountPreparer()
def test_delete_blobs_simple(self, resource_group, location, storage_account, storage_account_key):
Expand Down
5 changes: 5 additions & 0 deletions sdk/storage/azure-storage-blob/tests/test_container_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,11 @@ async def test_list_blobs_with_delimiter(self, resource_group, location, storage
self.assertNamedItemInContainer(resp, 'b/')
self.assertNamedItemInContainer(resp, 'blob4')

def test_batch_delete_empty_blob_list(self):
container_client = ContainerClient("https://mystorageaccount.blob.core.windows.net", "container")
blob_list = list()
container_client.delete_blobs(*blob_list)

@GlobalStorageAccountPreparer()
@AsyncStorageTestCase.await_prepared_test
async def test_delete_blobs_simple(self, resource_group, location, storage_account, storage_account_key):
Expand Down