From 6e64509a5c4629e68f15011c79c6c4924f6ec34c Mon Sep 17 00:00:00 2001 From: xiafu Date: Tue, 1 Sep 2020 00:53:30 -0700 Subject: [PATCH] add snapshot to get_blob_properties() response --- .../azure-storage-blob/azure/storage/blob/_blob_client.py | 1 + .../azure/storage/blob/aio/_blob_client_async.py | 1 + sdk/storage/azure-storage-blob/tests/test_common_blob.py | 5 +++-- .../azure-storage-blob/tests/test_common_blob_async.py | 5 +++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py index f78cf7319140..a9c783941c2c 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py @@ -1000,6 +1000,7 @@ def get_blob_properties(self, **kwargs): except StorageErrorException as error: process_storage_error(error) blob_props.name = self.blob_name + blob_props.snapshot = self.snapshot blob_props.container = self.container_name return blob_props # type: ignore diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_client_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_client_async.py index edf6e2dfc468..b90364c96af4 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_client_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_client_async.py @@ -540,6 +540,7 @@ async def get_blob_properties(self, **kwargs): except StorageErrorException as error: process_storage_error(error) blob_props.name = self.blob_name + blob_props.snapshot = self.snapshot blob_props.container = self.container_name return blob_props # type: ignore diff --git a/sdk/storage/azure-storage-blob/tests/test_common_blob.py b/sdk/storage/azure-storage-blob/tests/test_common_blob.py index cd53a51c8c8a..3ee96afb0147 100644 --- a/sdk/storage/azure-storage-blob/tests/test_common_blob.py +++ b/sdk/storage/azure-storage-blob/tests/test_common_blob.py @@ -193,10 +193,11 @@ def test_blob_snapshot_exists(self, resource_group, location, storage_account, s # Act blob = self.bsc.get_blob_client(self.container_name, blob_name, snapshot=snapshot) - exists = blob.get_blob_properties() + prop = blob.get_blob_properties() # Assert - self.assertTrue(exists) + self.assertTrue(prop) + self.assertEqual(snapshot['snapshot'], prop.snapshot) @GlobalStorageAccountPreparer() diff --git a/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py b/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py index c99a9a9fc152..8d38afa0813c 100644 --- a/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py @@ -220,10 +220,11 @@ async def test_blob_snapshot_exists(self, resource_group, location, storage_acco # Act blob = self.bsc.get_blob_client(self.container_name, blob_name, snapshot=snapshot) - exists = await blob.get_blob_properties() + prop = await blob.get_blob_properties() # Assert - self.assertTrue(exists) + self.assertTrue(prop) + self.assertEqual(snapshot['snapshot'], prop.snapshot) @GlobalStorageAccountPreparer()