From 50002fecb760c49e35434949f32fac4a875fe560 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 db4273e7ee3a..cf3a3e371761 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 @@ -1011,6 +1011,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 d88075ae87b9..6b1454c4c6c6 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 b2a7bc6235d8..fcaefbfcfe42 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()