From 8d55f6b63b84540444e3a08441aaf3d64ea3745f Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 19 Aug 2020 11:50:36 -0700 Subject: [PATCH 01/11] added feature and unit tests --- .../azure/storage/blob/_blob_client.py | 22 +++++++++++++++++++ .../tests/test_blob_access_conditions.py | 14 ++++++++++++ 2 files changed, 36 insertions(+) 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 b5366051d7ac..c2905c2fb076 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 @@ -918,6 +918,28 @@ def undelete_blob(self, **kwargs): except StorageErrorException as error: process_storage_error(error) + @distributed_trace() + def exists(self, timeout=None, version_id=None): + # type: (**Any) -> bool + """ + Returns True if a blob exists with the defined parameters, and returns + False otherwise. + + :param str version_id: + The version id parameter is an opaque DateTime + value that, when present, specifies the version of the blob to check if it exists. + :param int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + try: + self._client.blob.get_properties( + timeout=timeout, + version_id=version_id) + return True + except StorageErrorException: + return False + @distributed_trace def get_blob_properties(self, **kwargs): # type: (**Any) -> BlobProperties diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py index 876c8bb55849..095c89283ee0 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py @@ -715,6 +715,20 @@ def test_get_blob_properties_with_if_modified(self, resource_group, location, st self.assertEqual(properties.size, 11) self.assertEqual(properties.lease.status, 'unlocked') + @GlobalStorageAccountPreparer() + def test_if_blob_exists(self, resource_group, location, storage_account, storage_account_key): + bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key, connection_data_block_size=4 * 1024) + self._setup() + self._create_container_and_block_blob( + self.container_name, 'blob1', b'hello world', bsc) + test_datetime = (datetime.utcnow() - + timedelta(minutes=15)) + # Act + blob = bsc.get_blob_client(self.container_name, 'blob1') + blob_version_id = blob.get_blob_properties().get("version_id") + self.assertEqual(blob.exists(version_id=blob_version_id), True) + self.assertEqual(blob.exists(version_id="bad_version_id"), False) + @GlobalStorageAccountPreparer() def test_get_blob_properties_with_if_modified_fail(self, resource_group, location, storage_account, storage_account_key): bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key, connection_data_block_size=4 * 1024) From 899e89fe488fc372069965639b6bd941a25c1432 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Wed, 19 Aug 2020 13:55:05 -0700 Subject: [PATCH 02/11] fixed failing test issue --- ...access_conditions.test_if_blob_exists.yaml | 237 ++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml new file mode 100644 index 000000000000..4677cc74dbf7 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml @@ -0,0 +1,237 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Wed, 19 Aug 2020 20:52:58 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainerccc51342?restype=container + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Wed, 19 Aug 2020 20:52:58 GMT + etag: + - '"0x8D84481DAA59725"' + last-modified: + - Wed, 19 Aug 2020 20:52:58 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-version: + - '2019-12-12' + status: + code: 201 + message: Created +- request: + body: hello world + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '11' + Content-Type: + - application/octet-stream + If-None-Match: + - '*' + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-blob-type: + - BlockBlob + x-ms-date: + - Wed, 19 Aug 2020 20:52:58 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1 + response: + body: + string: '' + headers: + content-length: + - '0' + content-md5: + - XrY7u+Ae7tCTyyK7j1rNww== + date: + - Wed, 19 Aug 2020 20:52:58 GMT + etag: + - '"0x8D84481DABA7742"' + last-modified: + - Wed, 19 Aug 2020 20:52:58 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: + - vo7q9sPVKY0= + x-ms-request-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-19T20:52:58.4048450Z' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Wed, 19 Aug 2020 20:52:58 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1 + response: + body: + string: '' + headers: + accept-ranges: + - bytes + content-length: + - '11' + content-md5: + - XrY7u+Ae7tCTyyK7j1rNww== + content-type: + - application/octet-stream + date: + - Wed, 19 Aug 2020 20:52:58 GMT + etag: + - '"0x8D84481DABA7742"' + last-modified: + - Wed, 19 Aug 2020 20:52:58 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: + - Hot + x-ms-access-tier-inferred: + - 'true' + x-ms-blob-type: + - BlockBlob + x-ms-creation-time: + - Wed, 19 Aug 2020 20:52:58 GMT + x-ms-is-current-version: + - 'true' + x-ms-lease-state: + - available + x-ms-lease-status: + - unlocked + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-19T20:52:58.4048450Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Wed, 19 Aug 2020 20:52:58 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-19T20%3A52%3A58.4048450Z + response: + body: + string: '' + headers: + accept-ranges: + - bytes + content-length: + - '11' + content-md5: + - XrY7u+Ae7tCTyyK7j1rNww== + content-type: + - application/octet-stream + date: + - Wed, 19 Aug 2020 20:52:58 GMT + etag: + - '"0x8D84481DABA7742"' + last-modified: + - Wed, 19 Aug 2020 20:52:58 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: + - Hot + x-ms-access-tier-inferred: + - 'true' + x-ms-blob-type: + - BlockBlob + x-ms-creation-time: + - Wed, 19 Aug 2020 20:52:58 GMT + x-ms-is-current-version: + - 'true' + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-19T20:52:58.4048450Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Wed, 19 Aug 2020 20:52:59 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=bad_version_id + response: + body: + string: '' + headers: + date: + - Wed, 19 Aug 2020 20:52:58 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + status: + code: 400 + message: Value for one of the query parameters specified in the request URI + is invalid. +version: 1 From 45ffe31474b4e7684449b7ddf63627f585af1dbc Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Thu, 27 Aug 2020 11:58:32 -0700 Subject: [PATCH 03/11] added async method and more unit tests --- .../azure/storage/blob/_blob_client.py | 14 +- .../storage/blob/aio/_blob_client_async.py | 26 + ...access_conditions.test_if_blob_exists.yaml | 515 +++++++++++++++++- ..._conditions_async.test_if_blob_exists.yaml | 459 ++++++++++++++++ .../tests/test_blob_access_conditions.py | 25 +- .../test_blob_access_conditions_async.py | 32 ++ 6 files changed, 1033 insertions(+), 38 deletions(-) create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml 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 c2905c2fb076..c84ae62bf4b3 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 @@ -919,7 +919,7 @@ def undelete_blob(self, **kwargs): process_storage_error(error) @distributed_trace() - def exists(self, timeout=None, version_id=None): + def exists(self, **kwargs): # type: (**Any) -> bool """ Returns True if a blob exists with the defined parameters, and returns @@ -933,10 +933,14 @@ def exists(self, timeout=None, version_id=None): :returns: boolean """ try: - self._client.blob.get_properties( - timeout=timeout, - version_id=version_id) - return True + blob_props = self._client.blob.get_properties( + timeout=kwargs.pop('timeout', None), + version_id=kwargs.pop('version_id', None), + snapshot=self.snapshot, + cls=deserialize_blob_properties) + if blob_props and blob_props.is_current_version or blob_props and self.snapshot: + return True + return False except StorageErrorException: return False 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 3275d02004f8..3b7b9b09d787 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 @@ -460,6 +460,32 @@ async def undelete_blob(self, **kwargs): except StorageErrorException as error: process_storage_error(error) + @distributed_trace_async + async def exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a blob exists with the defined parameters, and returns + False otherwise. + + :param str version_id: + The version id parameter is an opaque DateTime + value that, when present, specifies the version of the blob to check if it exists. + :param int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + try: + blob_props = await self._client.blob.get_properties( + timeout=kwargs.pop('timeout', None), + version_id=kwargs.pop('version_id', None), + snapshot=self.snapshot, + cls=deserialize_blob_properties) + if blob_props and blob_props.is_current_version or blob_props and self.snapshot: + return True + return False + except StorageErrorException: + return False + @distributed_trace_async async def get_blob_properties(self, **kwargs): # type: (Any) -> BlobProperties diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml index 4677cc74dbf7..ad8e680eb498 100644 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml @@ -13,7 +13,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:02 GMT x-ms-version: - '2019-12-12' method: PUT @@ -25,11 +25,11 @@ interactions: content-length: - '0' date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT etag: - - '"0x8D84481DAA59725"' + - '"0x8D84ABB2016E211"' last-modified: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -57,7 +57,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT x-ms-version: - '2019-12-12' method: PUT @@ -71,11 +71,11 @@ interactions: content-md5: - XrY7u+Ae7tCTyyK7j1rNww== date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT etag: - - '"0x8D84481DABA7742"' + - '"0x8D84ABB20349EE4"' last-modified: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -85,7 +85,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-19T20:52:58.4048450Z' + - '2020-08-27T18:58:03.2594423Z' status: code: 201 message: Created @@ -101,7 +101,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -119,11 +119,11 @@ interactions: content-type: - application/octet-stream date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT etag: - - '"0x8D84481DABA7742"' + - '"0x8D84ABB20349EE4"' last-modified: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -133,7 +133,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -145,7 +145,153 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-19T20:52:58.4048450Z' + - '2020-08-27T18:58:03.2594423Z' + status: + code: 200 + message: OK +- request: + body: this is test content + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/octet-stream + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:03 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?blockid=MQ%3D%3D&comp=block + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Thu, 27 Aug 2020 18:58:03 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: + - wae/Ns62JRA= + x-ms-request-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + status: + code: 201 + message: Created +- request: + body: ' + + MQ==' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '83' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:03 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?comp=blocklist + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Thu, 27 Aug 2020 18:58:03 GMT + etag: + - '"0x8D84ABB207CFFC5"' + last-modified: + - Thu, 27 Aug 2020 18:58:03 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: + - iEgKfcNWGmY= + x-ms-request-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-27T18:58:03.7347824Z' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:03 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1 + response: + body: + string: '' + headers: + accept-ranges: + - bytes + content-length: + - '20' + content-type: + - application/octet-stream + date: + - Thu, 27 Aug 2020 18:58:03 GMT + etag: + - '"0x8D84ABB207CFFC5"' + last-modified: + - Thu, 27 Aug 2020 18:58:03 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: + - Hot + x-ms-access-tier-inferred: + - 'true' + x-ms-blob-type: + - BlockBlob + x-ms-creation-time: + - Thu, 27 Aug 2020 18:58:03 GMT + x-ms-is-current-version: + - 'true' + x-ms-lease-state: + - available + x-ms-lease-status: + - unlocked + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-27T18:58:03.7347824Z' status: code: 200 message: OK @@ -161,11 +307,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:04 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-19T20%3A52%3A58.4048450Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-27T18%3A58%3A03.2594423Z response: body: string: '' @@ -179,11 +325,63 @@ interactions: content-type: - application/octet-stream date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:04 GMT + etag: + - '"0x8D84ABB20349EE4"' + last-modified: + - Thu, 27 Aug 2020 18:58:03 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: + - Hot + x-ms-access-tier-inferred: + - 'true' + x-ms-blob-type: + - BlockBlob + x-ms-creation-time: + - Thu, 27 Aug 2020 18:58:03 GMT + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-27T18:58:03.2594423Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:04 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-27T18%3A58%3A03.7347824Z + response: + body: + string: '' + headers: + accept-ranges: + - bytes + content-length: + - '20' + content-type: + - application/octet-stream + date: + - Thu, 27 Aug 2020 18:58:04 GMT etag: - - '"0x8D84481DABA7742"' + - '"0x8D84ABB207CFFC5"' last-modified: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -193,7 +391,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:03 GMT x-ms-is-current-version: - 'true' x-ms-server-encrypted: @@ -201,7 +399,239 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-19T20:52:58.4048450Z' + - '2020-08-27T18:58:03.7347824Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:04 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?comp=snapshot + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Thu, 27 Aug 2020 18:58:04 GMT + etag: + - '"0x8D84ABB207CFFC5"' + last-modified: + - Thu, 27 Aug 2020 18:58:03 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-server-encrypted: + - 'false' + x-ms-snapshot: + - '2020-08-27T18:58:04.3282032Z' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-27T18:58:04.3292032Z' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:04 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-08-27T18:58:04.3282032Z + response: + body: + string: '' + headers: + accept-ranges: + - bytes + content-length: + - '20' + content-type: + - application/octet-stream + date: + - Thu, 27 Aug 2020 18:58:04 GMT + etag: + - '"0x8D84ABB207CFFC5"' + last-modified: + - Thu, 27 Aug 2020 18:58:03 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: + - Hot + x-ms-access-tier-inferred: + - 'true' + x-ms-blob-type: + - BlockBlob + x-ms-creation-time: + - Thu, 27 Aug 2020 18:58:03 GMT + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + status: + code: 200 + message: OK +- request: + body: this is additional test content + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '31' + Content-Type: + - application/octet-stream + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:04 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?blockid=MQ%3D%3D&comp=block + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Thu, 27 Aug 2020 18:58:04 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: + - npKkArwnhSg= + x-ms-request-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + status: + code: 201 + message: Created +- request: + body: ' + + MQ==' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '83' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:04 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?comp=blocklist + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Thu, 27 Aug 2020 18:58:04 GMT + etag: + - '"0x8D84ABB211BF4C4"' + last-modified: + - Thu, 27 Aug 2020 18:58:04 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: + - iEgKfcNWGmY= + x-ms-request-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-27T18:58:04.7755220Z' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:58:04 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-08-27T18:58:04.3282032Z + response: + body: + string: '' + headers: + accept-ranges: + - bytes + content-length: + - '20' + content-type: + - application/octet-stream + date: + - Thu, 27 Aug 2020 18:58:04 GMT + etag: + - '"0x8D84ABB207CFFC5"' + last-modified: + - Thu, 27 Aug 2020 18:58:03 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: + - Hot + x-ms-access-tier-inferred: + - 'true' + x-ms-blob-type: + - BlockBlob + x-ms-creation-time: + - Thu, 27 Aug 2020 18:58:03 GMT + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' status: code: 200 message: OK @@ -217,21 +647,50 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Wed, 19 Aug 2020 20:52:59 GMT + - Thu, 27 Aug 2020 18:58:05 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=bad_version_id + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1 response: body: string: '' headers: + accept-ranges: + - bytes + content-length: + - '31' + content-type: + - application/octet-stream date: - - Wed, 19 Aug 2020 20:52:58 GMT + - Thu, 27 Aug 2020 18:58:05 GMT + etag: + - '"0x8D84ABB211BF4C4"' + last-modified: + - Thu, 27 Aug 2020 18:58:04 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: + - Hot + x-ms-access-tier-inferred: + - 'true' + x-ms-blob-type: + - BlockBlob + x-ms-creation-time: + - Thu, 27 Aug 2020 18:58:04 GMT + x-ms-is-current-version: + - 'true' + x-ms-lease-state: + - available + x-ms-lease-status: + - unlocked + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2019-12-12' + x-ms-version-id: + - '2020-08-27T18:58:04.7755220Z' status: - code: 400 - message: Value for one of the query parameters specified in the request URI - is invalid. + code: 200 + message: OK version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml new file mode 100644 index 000000000000..c364805cfd0d --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml @@ -0,0 +1,459 @@ +interactions: +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:14 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf?restype=container + response: + body: + string: '' + headers: + content-length: '0' + date: Thu, 27 Aug 2020 18:57:14 GMT + etag: '"0x8D84ABB0340D379"' + last-modified: Thu, 27 Aug 2020 18:57:14 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-version: '2019-12-12' + status: + code: 201 + message: Created + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf?restype=container +- request: + body: hello world + headers: + Content-Length: + - '11' + Content-Type: + - application/octet-stream + If-None-Match: + - '*' + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-blob-type: + - BlockBlob + x-ms-date: + - Thu, 27 Aug 2020 18:57:14 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1 + response: + body: + string: '' + headers: + content-length: '0' + content-md5: XrY7u+Ae7tCTyyK7j1rNww== + date: Thu, 27 Aug 2020 18:57:14 GMT + etag: '"0x8D84ABB03550D28"' + last-modified: Thu, 27 Aug 2020 18:57:14 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: vo7q9sPVKY0= + x-ms-request-server-encrypted: 'true' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:14.8170536Z' + status: + code: 201 + message: Created + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1 +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:15 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1 + response: + body: + string: '' + headers: + accept-ranges: bytes + content-length: '11' + content-md5: XrY7u+Ae7tCTyyK7j1rNww== + content-type: application/octet-stream + date: Thu, 27 Aug 2020 18:57:14 GMT + etag: '"0x8D84ABB03550D28"' + last-modified: Thu, 27 Aug 2020 18:57:14 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: Hot + x-ms-access-tier-inferred: 'true' + x-ms-blob-type: BlockBlob + x-ms-creation-time: Thu, 27 Aug 2020 18:57:14 GMT + x-ms-is-current-version: 'true' + x-ms-lease-state: available + x-ms-lease-status: unlocked + x-ms-server-encrypted: 'true' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:14.8170536Z' + status: + code: 200 + message: OK + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1 +- request: + body: this is test content + headers: + Content-Length: + - '20' + Content-Type: + - application/octet-stream + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:15 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?blockid=MQ%3D%3D&comp=block + response: + body: + string: '' + headers: + content-length: '0' + date: Thu, 27 Aug 2020 18:57:14 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: wae/Ns62JRA= + x-ms-request-server-encrypted: 'true' + x-ms-version: '2019-12-12' + status: + code: 201 + message: Created + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?blockid=MQ%3D%3D&comp=block +- request: + body: ' + + MQ==' + headers: + Content-Length: + - '83' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:15 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?comp=blocklist + response: + body: + string: '' + headers: + content-length: '0' + date: Thu, 27 Aug 2020 18:57:14 GMT + etag: '"0x8D84ABB03A908C9"' + last-modified: Thu, 27 Aug 2020 18:57:15 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: iEgKfcNWGmY= + x-ms-request-server-encrypted: 'true' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:15.3684441Z' + status: + code: 201 + message: Created + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?comp=blocklist +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:15 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1 + response: + body: + string: '' + headers: + accept-ranges: bytes + content-length: '20' + content-type: application/octet-stream + date: Thu, 27 Aug 2020 18:57:14 GMT + etag: '"0x8D84ABB03A908C9"' + last-modified: Thu, 27 Aug 2020 18:57:15 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: Hot + x-ms-access-tier-inferred: 'true' + x-ms-blob-type: BlockBlob + x-ms-creation-time: Thu, 27 Aug 2020 18:57:15 GMT + x-ms-is-current-version: 'true' + x-ms-lease-state: available + x-ms-lease-status: unlocked + x-ms-server-encrypted: 'true' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:15.3684441Z' + status: + code: 200 + message: OK + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1 +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:15 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-27T18:57:14.8170536Z + response: + body: + string: '' + headers: + accept-ranges: bytes + content-length: '11' + content-md5: XrY7u+Ae7tCTyyK7j1rNww== + content-type: application/octet-stream + date: Thu, 27 Aug 2020 18:57:15 GMT + etag: '"0x8D84ABB03550D28"' + last-modified: Thu, 27 Aug 2020 18:57:14 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: Hot + x-ms-access-tier-inferred: 'true' + x-ms-blob-type: BlockBlob + x-ms-creation-time: Thu, 27 Aug 2020 18:57:14 GMT + x-ms-server-encrypted: 'true' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:14.8170536Z' + status: + code: 200 + message: OK + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-27T18:57:14.8170536Z +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:16 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-27T18:57:15.3684441Z + response: + body: + string: '' + headers: + accept-ranges: bytes + content-length: '20' + content-type: application/octet-stream + date: Thu, 27 Aug 2020 18:57:15 GMT + etag: '"0x8D84ABB03A908C9"' + last-modified: Thu, 27 Aug 2020 18:57:15 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: Hot + x-ms-access-tier-inferred: 'true' + x-ms-blob-type: BlockBlob + x-ms-creation-time: Thu, 27 Aug 2020 18:57:15 GMT + x-ms-is-current-version: 'true' + x-ms-server-encrypted: 'true' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:15.3684441Z' + status: + code: 200 + message: OK + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-27T18:57:15.3684441Z +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:16 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?comp=snapshot + response: + body: + string: '' + headers: + content-length: '0' + date: Thu, 27 Aug 2020 18:57:15 GMT + etag: '"0x8D84ABB03A908C9"' + last-modified: Thu, 27 Aug 2020 18:57:15 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-server-encrypted: 'false' + x-ms-snapshot: '2020-08-27T18:57:16.4842363Z' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:16.4852363Z' + status: + code: 201 + message: Created + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?comp=snapshot +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:16 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-08-27T18:57:16.4842363Z + response: + body: + string: '' + headers: + accept-ranges: bytes + content-length: '20' + content-type: application/octet-stream + date: Thu, 27 Aug 2020 18:57:15 GMT + etag: '"0x8D84ABB03A908C9"' + last-modified: Thu, 27 Aug 2020 18:57:15 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: Hot + x-ms-access-tier-inferred: 'true' + x-ms-blob-type: BlockBlob + x-ms-creation-time: Thu, 27 Aug 2020 18:57:15 GMT + x-ms-server-encrypted: 'true' + x-ms-version: '2019-12-12' + status: + code: 200 + message: OK + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-08-27T18:57:16.4842363Z +- request: + body: this is additional test content + headers: + Content-Length: + - '31' + Content-Type: + - application/octet-stream + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:16 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?blockid=MQ%3D%3D&comp=block + response: + body: + string: '' + headers: + content-length: '0' + date: Thu, 27 Aug 2020 18:57:16 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: npKkArwnhSg= + x-ms-request-server-encrypted: 'true' + x-ms-version: '2019-12-12' + status: + code: 201 + message: Created + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?blockid=MQ%3D%3D&comp=block +- request: + body: ' + + MQ==' + headers: + Content-Length: + - '83' + Content-Type: + - application/xml; charset=utf-8 + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:17 GMT + x-ms-version: + - '2019-12-12' + method: PUT + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?comp=blocklist + response: + body: + string: '' + headers: + content-length: '0' + date: Thu, 27 Aug 2020 18:57:16 GMT + etag: '"0x8D84ABB04A59834"' + last-modified: Thu, 27 Aug 2020 18:57:17 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-content-crc64: iEgKfcNWGmY= + x-ms-request-server-encrypted: 'true' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:17.0236228Z' + status: + code: 201 + message: Created + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?comp=blocklist +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:17 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-08-27T18:57:16.4842363Z + response: + body: + string: '' + headers: + accept-ranges: bytes + content-length: '20' + content-type: application/octet-stream + date: Thu, 27 Aug 2020 18:57:16 GMT + etag: '"0x8D84ABB03A908C9"' + last-modified: Thu, 27 Aug 2020 18:57:15 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: Hot + x-ms-access-tier-inferred: 'true' + x-ms-blob-type: BlockBlob + x-ms-creation-time: Thu, 27 Aug 2020 18:57:15 GMT + x-ms-server-encrypted: 'true' + x-ms-version: '2019-12-12' + status: + code: 200 + message: OK + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-08-27T18:57:16.4842363Z +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Thu, 27 Aug 2020 18:57:17 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1 + response: + body: + string: '' + headers: + accept-ranges: bytes + content-length: '31' + content-type: application/octet-stream + date: Thu, 27 Aug 2020 18:57:16 GMT + etag: '"0x8D84ABB04A59834"' + last-modified: Thu, 27 Aug 2020 18:57:17 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-access-tier: Hot + x-ms-access-tier-inferred: 'true' + x-ms-blob-type: BlockBlob + x-ms-creation-time: Thu, 27 Aug 2020 18:57:17 GMT + x-ms-is-current-version: 'true' + x-ms-lease-state: available + x-ms-lease-status: unlocked + x-ms-server-encrypted: 'true' + x-ms-version: '2019-12-12' + x-ms-version-id: '2020-08-27T18:57:17.0236228Z' + status: + code: 200 + message: OK + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1 +version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py index 095c89283ee0..c703a3bbc50a 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py @@ -721,13 +721,28 @@ def test_if_blob_exists(self, resource_group, location, storage_account, storage self._setup() self._create_container_and_block_blob( self.container_name, 'blob1', b'hello world', bsc) - test_datetime = (datetime.utcnow() - - timedelta(minutes=15)) # Act blob = bsc.get_blob_client(self.container_name, 'blob1') - blob_version_id = blob.get_blob_properties().get("version_id") - self.assertEqual(blob.exists(version_id=blob_version_id), True) - self.assertEqual(blob.exists(version_id="bad_version_id"), False) + old_blob_version_id = blob.get_blob_properties().get("version_id") + self.assertIsNotNone(old_blob_version_id) + blob.stage_block(block_id='1', data="this is test content") + blob.commit_block_list(['1']) + new_blob_version_id = blob.get_blob_properties().get("version_id") + + # Assert + self.assertEqual(blob.exists(version_id=old_blob_version_id), False) + self.assertEqual(blob.exists(version_id=new_blob_version_id), True) + + # Act + test_snapshot = blob.create_snapshot() + blob_snapshot = bsc.get_blob_client(self.container_name, 'blob1', snapshot=test_snapshot) + self.assertEqual(blob_snapshot.exists(), True) + blob.stage_block(block_id='1', data="this is additional test content") + blob.commit_block_list(['1']) + + # Assert + self.assertEqual(blob_snapshot.exists(), True) + self.assertEqual(blob.exists(), True) @GlobalStorageAccountPreparer() def test_get_blob_properties_with_if_modified_fail(self, resource_group, location, storage_account, storage_account_key): diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py index c7cb1af7b692..4f4849a49f86 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py @@ -744,6 +744,38 @@ async def test_set_blob_props_with_if_none_match_fail(self, resource_group, loca # Assert self.assertEqual(StorageErrorCode.condition_not_met, e.exception.error_code) + @GlobalStorageAccountPreparer() + @AsyncStorageTestCase.await_prepared_test + async def test_if_blob_exists(self, resource_group, location, storage_account, storage_account_key): + bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key, connection_data_block_size=4 * 1024) + self._setup() + await self._create_container_and_block_blob( + self.container_name, 'blob1', b'hello world', bsc) + # Act + blob = bsc.get_blob_client(self.container_name, 'blob1') + old_blob_props = await blob.get_blob_properties() + old_blob_version_id = old_blob_props.get("version_id") + self.assertIsNotNone(old_blob_version_id) + await blob.stage_block(block_id='1', data="this is test content") + await blob.commit_block_list(['1']) + new_blob_props = await blob.get_blob_properties() + new_blob_version_id = new_blob_props.get("version_id") + + # Assert + self.assertEqual(await blob.exists(version_id=old_blob_version_id), False) + self.assertEqual(await blob.exists(version_id=new_blob_version_id), True) + + # Act + test_snapshot = await blob.create_snapshot() + blob_snapshot = bsc.get_blob_client(self.container_name, 'blob1', snapshot=test_snapshot) + self.assertEqual(await blob_snapshot.exists(), True) + await blob.stage_block(block_id='1', data="this is additional test content") + await blob.commit_block_list(['1']) + + # Assert + self.assertEqual(await blob_snapshot.exists(), True) + self.assertEqual(await blob.exists(), True) + @GlobalStorageAccountPreparer() @AsyncStorageTestCase.await_prepared_test async def test_get_blob_properties_with_if_modified(self, resource_group, location, storage_account, storage_account_key): From 6034ca6f9670bc2a45cb2bbbf121bb44f2c280ad Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Sun, 30 Aug 2020 22:37:36 -0700 Subject: [PATCH 04/11] ffixed passed parameters --- .../azure/storage/blob/_blob_client.py | 6 +- .../storage/blob/aio/_blob_client_async.py | 6 +- ...access_conditions.test_if_blob_exists.yaml | 146 +++++++++--------- 3 files changed, 79 insertions(+), 79 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 c84ae62bf4b3..d6e5415445e6 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 @@ -18,6 +18,7 @@ import six from azure.core.tracing.decorator import distributed_trace +from azure.core.exceptions import ResourceNotFoundError from ._shared import encode_base64 from ._shared.base_client import StorageAccountHostsMixin, parse_connection_str, parse_query @@ -934,14 +935,13 @@ def exists(self, **kwargs): """ try: blob_props = self._client.blob.get_properties( - timeout=kwargs.pop('timeout', None), - version_id=kwargs.pop('version_id', None), + **kwargs, snapshot=self.snapshot, cls=deserialize_blob_properties) if blob_props and blob_props.is_current_version or blob_props and self.snapshot: return True return False - except StorageErrorException: + except ResourceNotFoundError: return False @distributed_trace 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 3b7b9b09d787..7047458e8723 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 @@ -11,6 +11,7 @@ ) from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.exceptions import ResourceNotFoundError from .._shared.base_client_async import AsyncStorageAccountHostsMixin from .._shared.policies_async import ExponentialRetry @@ -476,14 +477,13 @@ async def exists(self, **kwargs): """ try: blob_props = await self._client.blob.get_properties( - timeout=kwargs.pop('timeout', None), - version_id=kwargs.pop('version_id', None), + **kwargs, snapshot=self.snapshot, cls=deserialize_blob_properties) if blob_props and blob_props.is_current_version or blob_props and self.snapshot: return True return False - except StorageErrorException: + except ResourceNotFoundError: return False @distributed_trace_async diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml index ad8e680eb498..558dad7d83c7 100644 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml @@ -13,7 +13,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:02 GMT + - Mon, 31 Aug 2020 05:36:41 GMT x-ms-version: - '2019-12-12' method: PUT @@ -25,11 +25,11 @@ interactions: content-length: - '0' date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT etag: - - '"0x8D84ABB2016E211"' + - '"0x8D84D6FD7862D7D"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -57,7 +57,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT x-ms-version: - '2019-12-12' method: PUT @@ -71,11 +71,11 @@ interactions: content-md5: - XrY7u+Ae7tCTyyK7j1rNww== date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT etag: - - '"0x8D84ABB20349EE4"' + - '"0x8D84D6FD7AE3B3D"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -85,7 +85,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:03.2594423Z' + - '2020-08-31T05:36:42.8163668Z' status: code: 201 message: Created @@ -101,7 +101,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -119,11 +119,11 @@ interactions: content-type: - application/octet-stream date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT etag: - - '"0x8D84ABB20349EE4"' + - '"0x8D84D6FD7AE3B3D"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -133,7 +133,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -145,7 +145,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:03.2594423Z' + - '2020-08-31T05:36:42.8163668Z' status: code: 200 message: OK @@ -165,7 +165,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT x-ms-version: - '2019-12-12' method: PUT @@ -177,7 +177,7 @@ interactions: content-length: - '0' date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -207,7 +207,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT x-ms-version: - '2019-12-12' method: PUT @@ -219,11 +219,11 @@ interactions: content-length: - '0' date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT etag: - - '"0x8D84ABB207CFFC5"' + - '"0x8D84D6FD82A86B7"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -233,7 +233,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:03.7347824Z' + - '2020-08-31T05:36:43.6309447Z' status: code: 201 message: Created @@ -249,7 +249,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:44 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -265,11 +265,11 @@ interactions: content-type: - application/octet-stream date: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT etag: - - '"0x8D84ABB207CFFC5"' + - '"0x8D84D6FD82A86B7"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -279,7 +279,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -291,7 +291,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:03.7347824Z' + - '2020-08-31T05:36:43.6309447Z' status: code: 200 message: OK @@ -307,11 +307,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:44 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-27T18%3A58%3A03.2594423Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-31T05%3A36%3A42.8163668Z response: body: string: '' @@ -325,11 +325,11 @@ interactions: content-type: - application/octet-stream date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:43 GMT etag: - - '"0x8D84ABB20349EE4"' + - '"0x8D84D6FD7AE3B3D"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -339,13 +339,13 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:42 GMT x-ms-server-encrypted: - 'true' x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:03.2594423Z' + - '2020-08-31T05:36:42.8163668Z' status: code: 200 message: OK @@ -361,11 +361,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:44 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-27T18%3A58%3A03.7347824Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-31T05%3A36%3A43.6309447Z response: body: string: '' @@ -377,11 +377,11 @@ interactions: content-type: - application/octet-stream date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:44 GMT etag: - - '"0x8D84ABB207CFFC5"' + - '"0x8D84D6FD82A86B7"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -391,7 +391,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT x-ms-is-current-version: - 'true' x-ms-server-encrypted: @@ -399,7 +399,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:03.7347824Z' + - '2020-08-31T05:36:43.6309447Z' status: code: 200 message: OK @@ -417,7 +417,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:44 GMT x-ms-version: - '2019-12-12' method: PUT @@ -429,21 +429,21 @@ interactions: content-length: - '0' date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:44 GMT etag: - - '"0x8D84ABB207CFFC5"' + - '"0x8D84D6FD82A86B7"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-server-encrypted: - 'false' x-ms-snapshot: - - '2020-08-27T18:58:04.3282032Z' + - '2020-08-31T05:36:44.6326554Z' x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:04.3292032Z' + - '2020-08-31T05:36:44.6336554Z' status: code: 201 message: Created @@ -459,11 +459,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-08-27T18:58:04.3282032Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-08-31T05:36:44.6326554Z response: body: string: '' @@ -475,11 +475,11 @@ interactions: content-type: - application/octet-stream date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:44 GMT etag: - - '"0x8D84ABB207CFFC5"' + - '"0x8D84D6FD82A86B7"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -489,7 +489,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT x-ms-server-encrypted: - 'true' x-ms-version: @@ -513,7 +513,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT x-ms-version: - '2019-12-12' method: PUT @@ -525,7 +525,7 @@ interactions: content-length: - '0' date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:44 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -555,7 +555,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT x-ms-version: - '2019-12-12' method: PUT @@ -567,11 +567,11 @@ interactions: content-length: - '0' date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT etag: - - '"0x8D84ABB211BF4C4"' + - '"0x8D84D6FD9481182"' last-modified: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -581,7 +581,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:04.7755220Z' + - '2020-08-31T05:36:45.5032745Z' status: code: 201 message: Created @@ -597,11 +597,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-08-27T18:58:04.3282032Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-08-31T05:36:44.6326554Z response: body: string: '' @@ -613,11 +613,11 @@ interactions: content-type: - application/octet-stream date: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT etag: - - '"0x8D84ABB207CFFC5"' + - '"0x8D84D6FD82A86B7"' last-modified: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -627,7 +627,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Thu, 27 Aug 2020 18:58:03 GMT + - Mon, 31 Aug 2020 05:36:43 GMT x-ms-server-encrypted: - 'true' x-ms-version: @@ -647,7 +647,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:58:05 GMT + - Mon, 31 Aug 2020 05:36:46 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -663,11 +663,11 @@ interactions: content-type: - application/octet-stream date: - - Thu, 27 Aug 2020 18:58:05 GMT + - Mon, 31 Aug 2020 05:36:45 GMT etag: - - '"0x8D84ABB211BF4C4"' + - '"0x8D84D6FD9481182"' last-modified: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -677,7 +677,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Thu, 27 Aug 2020 18:58:04 GMT + - Mon, 31 Aug 2020 05:36:45 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -689,7 +689,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-27T18:58:04.7755220Z' + - '2020-08-31T05:36:45.5032745Z' status: code: 200 message: OK From f800b561711fb5b0be99a8dac665035d87ea6556 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Mon, 31 Aug 2020 09:39:36 -0700 Subject: [PATCH 05/11] fixed python 27 issue with kwargs --- .../azure-storage-blob/azure/storage/blob/_blob_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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 d6e5415445e6..66178200ab94 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 @@ -935,9 +935,9 @@ def exists(self, **kwargs): """ try: blob_props = self._client.blob.get_properties( - **kwargs, snapshot=self.snapshot, - cls=deserialize_blob_properties) + cls=deserialize_blob_properties, + **kwargs) if blob_props and blob_props.is_current_version or blob_props and self.snapshot: return True return False From 744b14e85f653e512253b32ca4b2db3ba512e926 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Mon, 31 Aug 2020 19:22:24 -0700 Subject: [PATCH 06/11] reset commit --- .../azure/storage/blob/_blob_client.py | 10 +- .../storage/blob/aio/_blob_client_async.py | 11 +- ...access_conditions.test_if_blob_exists.yaml | 180 +++++++++++------- ..._conditions_async.test_if_blob_exists.yaml | 176 +++++++++-------- .../tests/test_blob_access_conditions.py | 3 +- .../test_blob_access_conditions_async.py | 3 +- 6 files changed, 217 insertions(+), 166 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 66178200ab94..1919c2273328 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 @@ -18,7 +18,6 @@ import six from azure.core.tracing.decorator import distributed_trace -from azure.core.exceptions import ResourceNotFoundError from ._shared import encode_base64 from ._shared.base_client import StorageAccountHostsMixin, parse_connection_str, parse_query @@ -934,14 +933,11 @@ def exists(self, **kwargs): :returns: boolean """ try: - blob_props = self._client.blob.get_properties( + self._client.blob.get_properties( snapshot=self.snapshot, - cls=deserialize_blob_properties, **kwargs) - if blob_props and blob_props.is_current_version or blob_props and self.snapshot: - return True - return False - except ResourceNotFoundError: + return True + except StorageErrorException: return False @distributed_trace 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 7047458e8723..406a1ca37a10 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 @@ -476,14 +476,11 @@ async def exists(self, **kwargs): :returns: boolean """ try: - blob_props = await self._client.blob.get_properties( - **kwargs, + await self._client.blob.get_properties( snapshot=self.snapshot, - cls=deserialize_blob_properties) - if blob_props and blob_props.is_current_version or blob_props and self.snapshot: - return True - return False - except ResourceNotFoundError: + **kwargs) + return True + except StorageErrorException: return False @distributed_trace_async diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml index 558dad7d83c7..e592af6f5f1e 100644 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml @@ -13,7 +13,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:41 GMT + - Tue, 01 Sep 2020 02:21:54 GMT x-ms-version: - '2019-12-12' method: PUT @@ -25,11 +25,11 @@ interactions: content-length: - '0' date: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:53 GMT etag: - - '"0x8D84D6FD7862D7D"' + - '"0x8D84E1DCB27C357"' last-modified: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -57,7 +57,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-date: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:55 GMT x-ms-version: - '2019-12-12' method: PUT @@ -71,11 +71,11 @@ interactions: content-md5: - XrY7u+Ae7tCTyyK7j1rNww== date: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:53 GMT etag: - - '"0x8D84D6FD7AE3B3D"' + - '"0x8D84E1DCB56A7D1"' last-modified: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -85,7 +85,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:42.8163668Z' + - '2020-09-01T02:21:54.5397201Z' status: code: 201 message: Created @@ -101,7 +101,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -119,11 +119,11 @@ interactions: content-type: - application/octet-stream date: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:53 GMT etag: - - '"0x8D84D6FD7AE3B3D"' + - '"0x8D84E1DCB56A7D1"' last-modified: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -133,7 +133,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:54 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -145,7 +145,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:42.8163668Z' + - '2020-09-01T02:21:54.5397201Z' status: code: 200 message: OK @@ -165,7 +165,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT x-ms-version: - '2019-12-12' method: PUT @@ -177,7 +177,7 @@ interactions: content-length: - '0' date: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -207,7 +207,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:56 GMT x-ms-version: - '2019-12-12' method: PUT @@ -219,11 +219,11 @@ interactions: content-length: - '0' date: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:54 GMT etag: - - '"0x8D84D6FD82A86B7"' + - '"0x8D84E1DCBD8C0B9"' last-modified: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -233,7 +233,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:43.6309447Z' + - '2020-09-01T02:21:55.3933257Z' status: code: 201 message: Created @@ -249,7 +249,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:44 GMT + - Tue, 01 Sep 2020 02:21:56 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -265,11 +265,11 @@ interactions: content-type: - application/octet-stream date: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:54 GMT etag: - - '"0x8D84D6FD82A86B7"' + - '"0x8D84E1DCBD8C0B9"' last-modified: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -279,7 +279,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -291,7 +291,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:43.6309447Z' + - '2020-09-01T02:21:55.3933257Z' status: code: 200 message: OK @@ -307,11 +307,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:44 GMT + - Tue, 01 Sep 2020 02:21:56 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-31T05%3A36%3A42.8163668Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-09-01T02%3A21%3A54.5397201Z response: body: string: '' @@ -325,11 +325,11 @@ interactions: content-type: - application/octet-stream date: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:54 GMT etag: - - '"0x8D84D6FD7AE3B3D"' + - '"0x8D84E1DCB56A7D1"' last-modified: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -339,13 +339,13 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Mon, 31 Aug 2020 05:36:42 GMT + - Tue, 01 Sep 2020 02:21:54 GMT x-ms-server-encrypted: - 'true' x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:42.8163668Z' + - '2020-09-01T02:21:54.5397201Z' status: code: 200 message: OK @@ -361,11 +361,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:44 GMT + - Tue, 01 Sep 2020 02:21:56 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-31T05%3A36%3A43.6309447Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-09-01T02%3A21%3A55.3933257Z response: body: string: '' @@ -377,11 +377,11 @@ interactions: content-type: - application/octet-stream date: - - Mon, 31 Aug 2020 05:36:44 GMT + - Tue, 01 Sep 2020 02:21:55 GMT etag: - - '"0x8D84D6FD82A86B7"' + - '"0x8D84E1DCBD8C0B9"' last-modified: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -391,7 +391,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT x-ms-is-current-version: - 'true' x-ms-server-encrypted: @@ -399,10 +399,44 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:43.6309447Z' + - '2020-09-01T02:21:55.3933257Z' status: code: 200 message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Tue, 01 Sep 2020 02:21:57 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-08-21T21%3A24%3A15.3585832Z + response: + body: + string: '' + headers: + date: + - Tue, 01 Sep 2020 02:21:55 GMT + server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-ms-error-code: + - BlobNotFound + x-ms-version: + - '2019-12-12' + status: + code: 404 + message: The specified blob does not exist. - request: body: null headers: @@ -417,7 +451,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:44 GMT + - Tue, 01 Sep 2020 02:21:57 GMT x-ms-version: - '2019-12-12' method: PUT @@ -429,21 +463,21 @@ interactions: content-length: - '0' date: - - Mon, 31 Aug 2020 05:36:44 GMT + - Tue, 01 Sep 2020 02:21:55 GMT etag: - - '"0x8D84D6FD82A86B7"' + - '"0x8D84E1DCBD8C0B9"' last-modified: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-server-encrypted: - 'false' x-ms-snapshot: - - '2020-08-31T05:36:44.6326554Z' + - '2020-09-01T02:21:56.3920343Z' x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:44.6336554Z' + - '2020-09-01T02:21:56.3930343Z' status: code: 201 message: Created @@ -459,11 +493,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:57 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-08-31T05:36:44.6326554Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-09-01T02:21:56.3920343Z response: body: string: '' @@ -475,11 +509,11 @@ interactions: content-type: - application/octet-stream date: - - Mon, 31 Aug 2020 05:36:44 GMT + - Tue, 01 Sep 2020 02:21:55 GMT etag: - - '"0x8D84D6FD82A86B7"' + - '"0x8D84E1DCBD8C0B9"' last-modified: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -489,7 +523,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT x-ms-server-encrypted: - 'true' x-ms-version: @@ -513,7 +547,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:57 GMT x-ms-version: - '2019-12-12' method: PUT @@ -525,7 +559,7 @@ interactions: content-length: - '0' date: - - Mon, 31 Aug 2020 05:36:44 GMT + - Tue, 01 Sep 2020 02:21:56 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -555,7 +589,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:57 GMT x-ms-version: - '2019-12-12' method: PUT @@ -567,11 +601,11 @@ interactions: content-length: - '0' date: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:56 GMT etag: - - '"0x8D84D6FD9481182"' + - '"0x8D84E1DCCF7AB54"' last-modified: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:57 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -581,7 +615,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:45.5032745Z' + - '2020-09-01T02:21:57.2746623Z' status: code: 201 message: Created @@ -597,11 +631,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:58 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-08-31T05:36:44.6326554Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-09-01T02:21:56.3920343Z response: body: string: '' @@ -613,11 +647,11 @@ interactions: content-type: - application/octet-stream date: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:56 GMT etag: - - '"0x8D84D6FD82A86B7"' + - '"0x8D84E1DCBD8C0B9"' last-modified: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -627,7 +661,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Mon, 31 Aug 2020 05:36:43 GMT + - Tue, 01 Sep 2020 02:21:55 GMT x-ms-server-encrypted: - 'true' x-ms-version: @@ -647,7 +681,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Mon, 31 Aug 2020 05:36:46 GMT + - Tue, 01 Sep 2020 02:21:58 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -663,11 +697,11 @@ interactions: content-type: - application/octet-stream date: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:56 GMT etag: - - '"0x8D84D6FD9481182"' + - '"0x8D84E1DCCF7AB54"' last-modified: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:57 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -677,7 +711,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Mon, 31 Aug 2020 05:36:45 GMT + - Tue, 01 Sep 2020 02:21:57 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -689,7 +723,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-08-31T05:36:45.5032745Z' + - '2020-09-01T02:21:57.2746623Z' status: code: 200 message: OK diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml index c364805cfd0d..4682bf39052a 100644 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml @@ -5,7 +5,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:14 GMT + - Tue, 01 Sep 2020 02:21:09 GMT x-ms-version: - '2019-12-12' method: PUT @@ -15,9 +15,9 @@ interactions: string: '' headers: content-length: '0' - date: Thu, 27 Aug 2020 18:57:14 GMT - etag: '"0x8D84ABB0340D379"' - last-modified: Thu, 27 Aug 2020 18:57:14 GMT + date: Tue, 01 Sep 2020 02:21:09 GMT + etag: '"0x8D84E1DB05B8709"' + last-modified: Tue, 01 Sep 2020 02:21:09 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: '2019-12-12' status: @@ -38,7 +38,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-date: - - Thu, 27 Aug 2020 18:57:14 GMT + - Tue, 01 Sep 2020 02:21:10 GMT x-ms-version: - '2019-12-12' method: PUT @@ -49,14 +49,14 @@ interactions: headers: content-length: '0' content-md5: XrY7u+Ae7tCTyyK7j1rNww== - date: Thu, 27 Aug 2020 18:57:14 GMT - etag: '"0x8D84ABB03550D28"' - last-modified: Thu, 27 Aug 2020 18:57:14 GMT + date: Tue, 01 Sep 2020 02:21:09 GMT + etag: '"0x8D84E1DB074512D"' + last-modified: Tue, 01 Sep 2020 02:21:09 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: vo7q9sPVKY0= x-ms-request-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:14.8170536Z' + x-ms-version-id: '2020-09-01T02:21:09.4356269Z' status: code: 201 message: Created @@ -67,7 +67,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:15 GMT + - Tue, 01 Sep 2020 02:21:10 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -80,20 +80,20 @@ interactions: content-length: '11' content-md5: XrY7u+Ae7tCTyyK7j1rNww== content-type: application/octet-stream - date: Thu, 27 Aug 2020 18:57:14 GMT - etag: '"0x8D84ABB03550D28"' - last-modified: Thu, 27 Aug 2020 18:57:14 GMT + date: Tue, 01 Sep 2020 02:21:09 GMT + etag: '"0x8D84E1DB074512D"' + last-modified: Tue, 01 Sep 2020 02:21:09 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Thu, 27 Aug 2020 18:57:14 GMT + x-ms-creation-time: Tue, 01 Sep 2020 02:21:09 GMT x-ms-is-current-version: 'true' x-ms-lease-state: available x-ms-lease-status: unlocked x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:14.8170536Z' + x-ms-version-id: '2020-09-01T02:21:09.4356269Z' status: code: 200 message: OK @@ -108,7 +108,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:15 GMT + - Tue, 01 Sep 2020 02:21:10 GMT x-ms-version: - '2019-12-12' method: PUT @@ -118,7 +118,7 @@ interactions: string: '' headers: content-length: '0' - date: Thu, 27 Aug 2020 18:57:14 GMT + date: Tue, 01 Sep 2020 02:21:09 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: wae/Ns62JRA= x-ms-request-server-encrypted: 'true' @@ -139,7 +139,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:15 GMT + - Tue, 01 Sep 2020 02:21:11 GMT x-ms-version: - '2019-12-12' method: PUT @@ -149,14 +149,14 @@ interactions: string: '' headers: content-length: '0' - date: Thu, 27 Aug 2020 18:57:14 GMT - etag: '"0x8D84ABB03A908C9"' - last-modified: Thu, 27 Aug 2020 18:57:15 GMT + date: Tue, 01 Sep 2020 02:21:09 GMT + etag: '"0x8D84E1DB11D3302"' + last-modified: Tue, 01 Sep 2020 02:21:10 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: iEgKfcNWGmY= x-ms-request-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:15.3684441Z' + x-ms-version-id: '2020-09-01T02:21:10.5434130Z' status: code: 201 message: Created @@ -167,7 +167,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:15 GMT + - Tue, 01 Sep 2020 02:21:11 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -179,20 +179,20 @@ interactions: accept-ranges: bytes content-length: '20' content-type: application/octet-stream - date: Thu, 27 Aug 2020 18:57:14 GMT - etag: '"0x8D84ABB03A908C9"' - last-modified: Thu, 27 Aug 2020 18:57:15 GMT + date: Tue, 01 Sep 2020 02:21:10 GMT + etag: '"0x8D84E1DB11D3302"' + last-modified: Tue, 01 Sep 2020 02:21:10 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Thu, 27 Aug 2020 18:57:15 GMT + x-ms-creation-time: Tue, 01 Sep 2020 02:21:10 GMT x-ms-is-current-version: 'true' x-ms-lease-state: available x-ms-lease-status: unlocked x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:15.3684441Z' + x-ms-version-id: '2020-09-01T02:21:10.5434130Z' status: code: 200 message: OK @@ -203,11 +203,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:15 GMT + - Tue, 01 Sep 2020 02:21:11 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-27T18:57:14.8170536Z + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-01T02:21:09.4356269Z response: body: string: '' @@ -216,32 +216,32 @@ interactions: content-length: '11' content-md5: XrY7u+Ae7tCTyyK7j1rNww== content-type: application/octet-stream - date: Thu, 27 Aug 2020 18:57:15 GMT - etag: '"0x8D84ABB03550D28"' - last-modified: Thu, 27 Aug 2020 18:57:14 GMT + date: Tue, 01 Sep 2020 02:21:10 GMT + etag: '"0x8D84E1DB074512D"' + last-modified: Tue, 01 Sep 2020 02:21:09 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Thu, 27 Aug 2020 18:57:14 GMT + x-ms-creation-time: Tue, 01 Sep 2020 02:21:09 GMT x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:14.8170536Z' + x-ms-version-id: '2020-09-01T02:21:09.4356269Z' status: code: 200 message: OK - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-27T18:57:14.8170536Z + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-01T02:21:09.4356269Z - request: body: null headers: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:16 GMT + - Tue, 01 Sep 2020 02:21:12 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-27T18:57:15.3684441Z + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-01T02:21:10.5434130Z response: body: string: '' @@ -249,29 +249,51 @@ interactions: accept-ranges: bytes content-length: '20' content-type: application/octet-stream - date: Thu, 27 Aug 2020 18:57:15 GMT - etag: '"0x8D84ABB03A908C9"' - last-modified: Thu, 27 Aug 2020 18:57:15 GMT + date: Tue, 01 Sep 2020 02:21:11 GMT + etag: '"0x8D84E1DB11D3302"' + last-modified: Tue, 01 Sep 2020 02:21:10 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Thu, 27 Aug 2020 18:57:15 GMT + x-ms-creation-time: Tue, 01 Sep 2020 02:21:10 GMT x-ms-is-current-version: 'true' x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:15.3684441Z' + x-ms-version-id: '2020-09-01T02:21:10.5434130Z' status: code: 200 message: OK - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-27T18:57:15.3684441Z + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-01T02:21:10.5434130Z - request: body: null headers: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:16 GMT + - Tue, 01 Sep 2020 02:21:12 GMT + x-ms-version: + - '2019-12-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=bad_version_id + response: + body: + string: '' + headers: + date: Tue, 01 Sep 2020 02:21:11 GMT + server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + status: + code: 400 + message: Value for one of the query parameters specified in the request URI + is invalid. + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=bad_version_id +- request: + body: null + headers: + User-Agent: + - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) + x-ms-date: + - Tue, 01 Sep 2020 02:21:13 GMT x-ms-version: - '2019-12-12' method: PUT @@ -281,14 +303,14 @@ interactions: string: '' headers: content-length: '0' - date: Thu, 27 Aug 2020 18:57:15 GMT - etag: '"0x8D84ABB03A908C9"' - last-modified: Thu, 27 Aug 2020 18:57:15 GMT + date: Tue, 01 Sep 2020 02:21:12 GMT + etag: '"0x8D84E1DB11D3302"' + last-modified: Tue, 01 Sep 2020 02:21:10 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-server-encrypted: 'false' - x-ms-snapshot: '2020-08-27T18:57:16.4842363Z' + x-ms-snapshot: '2020-09-01T02:21:13.4454804Z' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:16.4852363Z' + x-ms-version-id: '2020-09-01T02:21:13.4464804Z' status: code: 201 message: Created @@ -299,11 +321,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:16 GMT + - Tue, 01 Sep 2020 02:21:14 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-08-27T18:57:16.4842363Z + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-01T02:21:13.4454804Z response: body: string: '' @@ -311,20 +333,20 @@ interactions: accept-ranges: bytes content-length: '20' content-type: application/octet-stream - date: Thu, 27 Aug 2020 18:57:15 GMT - etag: '"0x8D84ABB03A908C9"' - last-modified: Thu, 27 Aug 2020 18:57:15 GMT + date: Tue, 01 Sep 2020 02:21:13 GMT + etag: '"0x8D84E1DB11D3302"' + last-modified: Tue, 01 Sep 2020 02:21:10 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Thu, 27 Aug 2020 18:57:15 GMT + x-ms-creation-time: Tue, 01 Sep 2020 02:21:10 GMT x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' status: code: 200 message: OK - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-08-27T18:57:16.4842363Z + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-01T02:21:13.4454804Z - request: body: this is additional test content headers: @@ -335,7 +357,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:16 GMT + - Tue, 01 Sep 2020 02:21:14 GMT x-ms-version: - '2019-12-12' method: PUT @@ -345,7 +367,7 @@ interactions: string: '' headers: content-length: '0' - date: Thu, 27 Aug 2020 18:57:16 GMT + date: Tue, 01 Sep 2020 02:21:13 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: npKkArwnhSg= x-ms-request-server-encrypted: 'true' @@ -366,7 +388,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:17 GMT + - Tue, 01 Sep 2020 02:21:15 GMT x-ms-version: - '2019-12-12' method: PUT @@ -376,14 +398,14 @@ interactions: string: '' headers: content-length: '0' - date: Thu, 27 Aug 2020 18:57:16 GMT - etag: '"0x8D84ABB04A59834"' - last-modified: Thu, 27 Aug 2020 18:57:17 GMT + date: Tue, 01 Sep 2020 02:21:13 GMT + etag: '"0x8D84E1DB37328BC"' + last-modified: Tue, 01 Sep 2020 02:21:14 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: iEgKfcNWGmY= x-ms-request-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:17.0236228Z' + x-ms-version-id: '2020-09-01T02:21:14.4622028Z' status: code: 201 message: Created @@ -394,11 +416,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:17 GMT + - Tue, 01 Sep 2020 02:21:15 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-08-27T18:57:16.4842363Z + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-01T02:21:13.4454804Z response: body: string: '' @@ -406,27 +428,27 @@ interactions: accept-ranges: bytes content-length: '20' content-type: application/octet-stream - date: Thu, 27 Aug 2020 18:57:16 GMT - etag: '"0x8D84ABB03A908C9"' - last-modified: Thu, 27 Aug 2020 18:57:15 GMT + date: Tue, 01 Sep 2020 02:21:14 GMT + etag: '"0x8D84E1DB11D3302"' + last-modified: Tue, 01 Sep 2020 02:21:10 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Thu, 27 Aug 2020 18:57:15 GMT + x-ms-creation-time: Tue, 01 Sep 2020 02:21:10 GMT x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' status: code: 200 message: OK - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-08-27T18:57:16.4842363Z + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-01T02:21:13.4454804Z - request: body: null headers: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Thu, 27 Aug 2020 18:57:17 GMT + - Tue, 01 Sep 2020 02:21:15 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -438,20 +460,20 @@ interactions: accept-ranges: bytes content-length: '31' content-type: application/octet-stream - date: Thu, 27 Aug 2020 18:57:16 GMT - etag: '"0x8D84ABB04A59834"' - last-modified: Thu, 27 Aug 2020 18:57:17 GMT + date: Tue, 01 Sep 2020 02:21:14 GMT + etag: '"0x8D84E1DB37328BC"' + last-modified: Tue, 01 Sep 2020 02:21:14 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Thu, 27 Aug 2020 18:57:17 GMT + x-ms-creation-time: Tue, 01 Sep 2020 02:21:14 GMT x-ms-is-current-version: 'true' x-ms-lease-state: available x-ms-lease-status: unlocked x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-08-27T18:57:17.0236228Z' + x-ms-version-id: '2020-09-01T02:21:14.4622028Z' status: code: 200 message: OK diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py index c703a3bbc50a..5721447f62c5 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py @@ -730,8 +730,9 @@ def test_if_blob_exists(self, resource_group, location, storage_account, storage new_blob_version_id = blob.get_blob_properties().get("version_id") # Assert - self.assertEqual(blob.exists(version_id=old_blob_version_id), False) + self.assertEqual(blob.exists(version_id=old_blob_version_id), True) self.assertEqual(blob.exists(version_id=new_blob_version_id), True) + self.assertEqual(blob.exists(version_id="2020-08-21T21:24:15.3585832Z"), False) # Act test_snapshot = blob.create_snapshot() diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py index 4f4849a49f86..3b6b6eacf700 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py @@ -762,8 +762,9 @@ async def test_if_blob_exists(self, resource_group, location, storage_account, s new_blob_version_id = new_blob_props.get("version_id") # Assert - self.assertEqual(await blob.exists(version_id=old_blob_version_id), False) + self.assertEqual(await blob.exists(version_id=old_blob_version_id), True) self.assertEqual(await blob.exists(version_id=new_blob_version_id), True) + self.assertEqual(await blob.exists(version_id="bad_version_id"), False) # Act test_snapshot = await blob.create_snapshot() From 6138e3ddbebc3cca4ec17982365918ef11f7b759 Mon Sep 17 00:00:00 2001 From: tasherif-msft <69483382+tasherif-msft@users.noreply.github.com> Date: Mon, 31 Aug 2020 22:54:28 -0700 Subject: [PATCH 07/11] Update _blob_client_async.py removed unused import, fixed linter --- .../azure/storage/blob/aio/_blob_client_async.py | 1 - 1 file changed, 1 deletion(-) 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 406a1ca37a10..4cec6df1b82f 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 @@ -11,7 +11,6 @@ ) from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.exceptions import ResourceNotFoundError from .._shared.base_client_async import AsyncStorageAccountHostsMixin from .._shared.policies_async import ExponentialRetry From bddb476b5ce4ca1067e3ab78010271139d9f551a Mon Sep 17 00:00:00 2001 From: tasherif-msft <69483382+tasherif-msft@users.noreply.github.com> Date: Thu, 3 Sep 2020 14:38:28 -0700 Subject: [PATCH 08/11] Update sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_client_async.py Co-authored-by: Xiaoxi Fu <49707495+xiafu-msft@users.noreply.github.com> --- .../azure/storage/blob/aio/_blob_client_async.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 4cec6df1b82f..eeb2cbcf9814 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 @@ -479,8 +479,11 @@ async def exists(self, **kwargs): snapshot=self.snapshot, **kwargs) return True - except StorageErrorException: - return False + except StorageErrorException as error: + try: + process_storage_error(error) + except ResourceNotFoundError: + return False @distributed_trace_async async def get_blob_properties(self, **kwargs): From 847ae15f321283a30d438c63532afec00aa5ac89 Mon Sep 17 00:00:00 2001 From: tasherif-msft <69483382+tasherif-msft@users.noreply.github.com> Date: Thu, 3 Sep 2020 14:38:36 -0700 Subject: [PATCH 09/11] Update sdk/storage/azure-storage-blob/azure/storage/blob/_blob_client.py Co-authored-by: Xiaoxi Fu <49707495+xiafu-msft@users.noreply.github.com> --- .../azure-storage-blob/azure/storage/blob/_blob_client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 1919c2273328..bd3ecaaf9259 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 @@ -937,8 +937,11 @@ def exists(self, **kwargs): snapshot=self.snapshot, **kwargs) return True - except StorageErrorException: - return False + except StorageErrorException as error: + try: + process_storage_error(error) + except ResourceNotFoundError: + return False @distributed_trace def get_blob_properties(self, **kwargs): From 67f1d8eb0b462e437fa6a10cc395f12f9459b52f Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Fri, 4 Sep 2020 11:47:25 -0700 Subject: [PATCH 10/11] fixed failing tests --- .../azure/storage/blob/_blob_client.py | 1 + .../storage/blob/aio/_blob_client_async.py | 2 + ...access_conditions.test_if_blob_exists.yaml | 150 ++++++++-------- ..._conditions_async.test_if_blob_exists.yaml | 170 +++++++++--------- .../test_blob_access_conditions_async.py | 2 +- 5 files changed, 165 insertions(+), 160 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 bd3ecaaf9259..ad499522c6c2 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 @@ -55,6 +55,7 @@ from ._models import BlobType, BlobBlock, BlobProperties, BlobQueryError from ._download import StorageStreamDownloader from ._lease import BlobLeaseClient, get_access_conditions +from azure.core.exceptions import ResourceNotFoundError if TYPE_CHECKING: from datetime import datetime 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 eeb2cbcf9814..b5a972a81d70 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 @@ -30,6 +30,8 @@ from .._lease import get_access_conditions from ._lease_async import BlobLeaseClient from ._download_async import StorageStreamDownloader +from azure.core.exceptions import ResourceNotFoundError + if TYPE_CHECKING: from datetime import datetime diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml index e592af6f5f1e..4cd261819afe 100644 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.test_if_blob_exists.yaml @@ -13,7 +13,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:53 GMT x-ms-version: - '2019-12-12' method: PUT @@ -25,11 +25,11 @@ interactions: content-length: - '0' date: - - Tue, 01 Sep 2020 02:21:53 GMT + - Fri, 04 Sep 2020 18:46:52 GMT etag: - - '"0x8D84E1DCB27C357"' + - '"0x8D85102E4833C1D"' last-modified: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:53 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -57,7 +57,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-date: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-version: - '2019-12-12' method: PUT @@ -71,11 +71,11 @@ interactions: content-md5: - XrY7u+Ae7tCTyyK7j1rNww== date: - - Tue, 01 Sep 2020 02:21:53 GMT + - Fri, 04 Sep 2020 18:46:54 GMT etag: - - '"0x8D84E1DCB56A7D1"' + - '"0x8D85102E49BFD6D"' last-modified: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -85,7 +85,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:54.5397201Z' + - '2020-09-04T18:46:54.0137837Z' status: code: 201 message: Created @@ -101,7 +101,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -119,11 +119,11 @@ interactions: content-type: - application/octet-stream date: - - Tue, 01 Sep 2020 02:21:53 GMT + - Fri, 04 Sep 2020 18:46:54 GMT etag: - - '"0x8D84E1DCB56A7D1"' + - '"0x8D85102E49BFD6D"' last-modified: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -133,7 +133,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -145,7 +145,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:54.5397201Z' + - '2020-09-04T18:46:54.0137837Z' status: code: 200 message: OK @@ -165,7 +165,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-version: - '2019-12-12' method: PUT @@ -177,7 +177,7 @@ interactions: content-length: - '0' date: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -207,7 +207,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:56 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-version: - '2019-12-12' method: PUT @@ -219,11 +219,11 @@ interactions: content-length: - '0' date: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT etag: - - '"0x8D84E1DCBD8C0B9"' + - '"0x8D85102E4E26222"' last-modified: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -233,7 +233,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:55.3933257Z' + - '2020-09-04T18:46:54.4761138Z' status: code: 201 message: Created @@ -249,7 +249,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:56 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -265,11 +265,11 @@ interactions: content-type: - application/octet-stream date: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT etag: - - '"0x8D84E1DCBD8C0B9"' + - '"0x8D85102E4E26222"' last-modified: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -279,7 +279,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -291,7 +291,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:55.3933257Z' + - '2020-09-04T18:46:54.4761138Z' status: code: 200 message: OK @@ -307,11 +307,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:56 GMT + - Fri, 04 Sep 2020 18:46:55 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-09-01T02%3A21%3A54.5397201Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-09-04T18%3A46%3A54.0137837Z response: body: string: '' @@ -325,11 +325,11 @@ interactions: content-type: - application/octet-stream date: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT etag: - - '"0x8D84E1DCB56A7D1"' + - '"0x8D85102E49BFD6D"' last-modified: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -339,13 +339,13 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Tue, 01 Sep 2020 02:21:54 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-server-encrypted: - 'true' x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:54.5397201Z' + - '2020-09-04T18:46:54.0137837Z' status: code: 200 message: OK @@ -361,11 +361,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:56 GMT + - Fri, 04 Sep 2020 18:46:55 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-09-01T02%3A21%3A55.3933257Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?versionid=2020-09-04T18%3A46%3A54.4761138Z response: body: string: '' @@ -377,11 +377,11 @@ interactions: content-type: - application/octet-stream date: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT etag: - - '"0x8D84E1DCBD8C0B9"' + - '"0x8D85102E4E26222"' last-modified: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -391,7 +391,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-is-current-version: - 'true' x-ms-server-encrypted: @@ -399,7 +399,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:55.3933257Z' + - '2020-09-04T18:46:54.4761138Z' status: code: 200 message: OK @@ -415,7 +415,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:57 GMT + - Fri, 04 Sep 2020 18:46:55 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -425,7 +425,7 @@ interactions: string: '' headers: date: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -451,7 +451,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:57 GMT + - Fri, 04 Sep 2020 18:46:55 GMT x-ms-version: - '2019-12-12' method: PUT @@ -463,21 +463,21 @@ interactions: content-length: - '0' date: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:55 GMT etag: - - '"0x8D84E1DCBD8C0B9"' + - '"0x8D85102E4E26222"' last-modified: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-server-encrypted: - 'false' x-ms-snapshot: - - '2020-09-01T02:21:56.3920343Z' + - '2020-09-04T18:46:55.2236480Z' x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:56.3930343Z' + - '2020-09-04T18:46:55.2246480Z' status: code: 201 message: Created @@ -493,11 +493,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:57 GMT + - Fri, 04 Sep 2020 18:46:55 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-09-01T02:21:56.3920343Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-09-04T18:46:55.2236480Z response: body: string: '' @@ -509,11 +509,11 @@ interactions: content-type: - application/octet-stream date: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:55 GMT etag: - - '"0x8D84E1DCBD8C0B9"' + - '"0x8D85102E4E26222"' last-modified: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -523,7 +523,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-server-encrypted: - 'true' x-ms-version: @@ -547,7 +547,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:57 GMT + - Fri, 04 Sep 2020 18:46:55 GMT x-ms-version: - '2019-12-12' method: PUT @@ -559,7 +559,7 @@ interactions: content-length: - '0' date: - - Tue, 01 Sep 2020 02:21:56 GMT + - Fri, 04 Sep 2020 18:46:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -589,7 +589,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:57 GMT + - Fri, 04 Sep 2020 18:46:56 GMT x-ms-version: - '2019-12-12' method: PUT @@ -601,11 +601,11 @@ interactions: content-length: - '0' date: - - Tue, 01 Sep 2020 02:21:56 GMT + - Fri, 04 Sep 2020 18:46:55 GMT etag: - - '"0x8D84E1DCCF7AB54"' + - '"0x8D85102E599C5B2"' last-modified: - - Tue, 01 Sep 2020 02:21:57 GMT + - Fri, 04 Sep 2020 18:46:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: @@ -615,7 +615,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:57.2746623Z' + - '2020-09-04T18:46:55.6789721Z' status: code: 201 message: Created @@ -631,11 +631,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:58 GMT + - Fri, 04 Sep 2020 18:46:56 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-09-01T02:21:56.3920343Z + uri: https://storagename.blob.core.windows.net/utcontainerccc51342/blob1?snapshot=2020-09-04T18:46:55.2236480Z response: body: string: '' @@ -647,11 +647,11 @@ interactions: content-type: - application/octet-stream date: - - Tue, 01 Sep 2020 02:21:56 GMT + - Fri, 04 Sep 2020 18:46:55 GMT etag: - - '"0x8D84E1DCBD8C0B9"' + - '"0x8D85102E4E26222"' last-modified: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -661,7 +661,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Tue, 01 Sep 2020 02:21:55 GMT + - Fri, 04 Sep 2020 18:46:54 GMT x-ms-server-encrypted: - 'true' x-ms-version: @@ -681,7 +681,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:58 GMT + - Fri, 04 Sep 2020 18:46:56 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -697,11 +697,11 @@ interactions: content-type: - application/octet-stream date: - - Tue, 01 Sep 2020 02:21:56 GMT + - Fri, 04 Sep 2020 18:46:55 GMT etag: - - '"0x8D84E1DCCF7AB54"' + - '"0x8D85102E599C5B2"' last-modified: - - Tue, 01 Sep 2020 02:21:57 GMT + - Fri, 04 Sep 2020 18:46:55 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: @@ -711,7 +711,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-creation-time: - - Tue, 01 Sep 2020 02:21:57 GMT + - Fri, 04 Sep 2020 18:46:55 GMT x-ms-is-current-version: - 'true' x-ms-lease-state: @@ -723,7 +723,7 @@ interactions: x-ms-version: - '2019-12-12' x-ms-version-id: - - '2020-09-01T02:21:57.2746623Z' + - '2020-09-04T18:46:55.6789721Z' status: code: 200 message: OK diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml index 4682bf39052a..1efaa06c1971 100644 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.test_if_blob_exists.yaml @@ -5,7 +5,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:09 GMT + - Fri, 04 Sep 2020 18:46:41 GMT x-ms-version: - '2019-12-12' method: PUT @@ -15,9 +15,9 @@ interactions: string: '' headers: content-length: '0' - date: Tue, 01 Sep 2020 02:21:09 GMT - etag: '"0x8D84E1DB05B8709"' - last-modified: Tue, 01 Sep 2020 02:21:09 GMT + date: Fri, 04 Sep 2020 18:46:40 GMT + etag: '"0x8D85102DCED6139"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: '2019-12-12' status: @@ -38,7 +38,7 @@ interactions: x-ms-blob-type: - BlockBlob x-ms-date: - - Tue, 01 Sep 2020 02:21:10 GMT + - Fri, 04 Sep 2020 18:46:41 GMT x-ms-version: - '2019-12-12' method: PUT @@ -49,14 +49,14 @@ interactions: headers: content-length: '0' content-md5: XrY7u+Ae7tCTyyK7j1rNww== - date: Tue, 01 Sep 2020 02:21:09 GMT - etag: '"0x8D84E1DB074512D"' - last-modified: Tue, 01 Sep 2020 02:21:09 GMT + date: Fri, 04 Sep 2020 18:46:40 GMT + etag: '"0x8D85102DCFA8B6D"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: vo7q9sPVKY0= x-ms-request-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:09.4356269Z' + x-ms-version-id: '2020-09-04T18:46:41.2126852Z' status: code: 201 message: Created @@ -67,7 +67,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:10 GMT + - Fri, 04 Sep 2020 18:46:41 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -80,20 +80,20 @@ interactions: content-length: '11' content-md5: XrY7u+Ae7tCTyyK7j1rNww== content-type: application/octet-stream - date: Tue, 01 Sep 2020 02:21:09 GMT - etag: '"0x8D84E1DB074512D"' - last-modified: Tue, 01 Sep 2020 02:21:09 GMT + date: Fri, 04 Sep 2020 18:46:40 GMT + etag: '"0x8D85102DCFA8B6D"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Tue, 01 Sep 2020 02:21:09 GMT + x-ms-creation-time: Fri, 04 Sep 2020 18:46:41 GMT x-ms-is-current-version: 'true' x-ms-lease-state: available x-ms-lease-status: unlocked x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:09.4356269Z' + x-ms-version-id: '2020-09-04T18:46:41.2126852Z' status: code: 200 message: OK @@ -108,7 +108,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:10 GMT + - Fri, 04 Sep 2020 18:46:41 GMT x-ms-version: - '2019-12-12' method: PUT @@ -118,7 +118,7 @@ interactions: string: '' headers: content-length: '0' - date: Tue, 01 Sep 2020 02:21:09 GMT + date: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: wae/Ns62JRA= x-ms-request-server-encrypted: 'true' @@ -139,7 +139,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:11 GMT + - Fri, 04 Sep 2020 18:46:42 GMT x-ms-version: - '2019-12-12' method: PUT @@ -149,14 +149,14 @@ interactions: string: '' headers: content-length: '0' - date: Tue, 01 Sep 2020 02:21:09 GMT - etag: '"0x8D84E1DB11D3302"' - last-modified: Tue, 01 Sep 2020 02:21:10 GMT + date: Fri, 04 Sep 2020 18:46:41 GMT + etag: '"0x8D85102DD486B76"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: iEgKfcNWGmY= x-ms-request-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:10.5434130Z' + x-ms-version-id: '2020-09-04T18:46:41.7230470Z' status: code: 201 message: Created @@ -167,7 +167,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:11 GMT + - Fri, 04 Sep 2020 18:46:42 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -179,20 +179,20 @@ interactions: accept-ranges: bytes content-length: '20' content-type: application/octet-stream - date: Tue, 01 Sep 2020 02:21:10 GMT - etag: '"0x8D84E1DB11D3302"' - last-modified: Tue, 01 Sep 2020 02:21:10 GMT + date: Fri, 04 Sep 2020 18:46:41 GMT + etag: '"0x8D85102DD486B76"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Tue, 01 Sep 2020 02:21:10 GMT + x-ms-creation-time: Fri, 04 Sep 2020 18:46:41 GMT x-ms-is-current-version: 'true' x-ms-lease-state: available x-ms-lease-status: unlocked x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:10.5434130Z' + x-ms-version-id: '2020-09-04T18:46:41.7230470Z' status: code: 200 message: OK @@ -203,11 +203,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:11 GMT + - Fri, 04 Sep 2020 18:46:42 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-01T02:21:09.4356269Z + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-04T18:46:41.2126852Z response: body: string: '' @@ -216,32 +216,32 @@ interactions: content-length: '11' content-md5: XrY7u+Ae7tCTyyK7j1rNww== content-type: application/octet-stream - date: Tue, 01 Sep 2020 02:21:10 GMT - etag: '"0x8D84E1DB074512D"' - last-modified: Tue, 01 Sep 2020 02:21:09 GMT + date: Fri, 04 Sep 2020 18:46:41 GMT + etag: '"0x8D85102DCFA8B6D"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Tue, 01 Sep 2020 02:21:09 GMT + x-ms-creation-time: Fri, 04 Sep 2020 18:46:41 GMT x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:09.4356269Z' + x-ms-version-id: '2020-09-04T18:46:41.2126852Z' status: code: 200 message: OK - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-01T02:21:09.4356269Z + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-04T18:46:41.2126852Z - request: body: null headers: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:12 GMT + - Fri, 04 Sep 2020 18:46:42 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-01T02:21:10.5434130Z + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-04T18:46:41.7230470Z response: body: string: '' @@ -249,51 +249,53 @@ interactions: accept-ranges: bytes content-length: '20' content-type: application/octet-stream - date: Tue, 01 Sep 2020 02:21:11 GMT - etag: '"0x8D84E1DB11D3302"' - last-modified: Tue, 01 Sep 2020 02:21:10 GMT + date: Fri, 04 Sep 2020 18:46:42 GMT + etag: '"0x8D85102DD486B76"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Tue, 01 Sep 2020 02:21:10 GMT + x-ms-creation-time: Fri, 04 Sep 2020 18:46:41 GMT x-ms-is-current-version: 'true' x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:10.5434130Z' + x-ms-version-id: '2020-09-04T18:46:41.7230470Z' status: code: 200 message: OK - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-01T02:21:10.5434130Z + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-09-04T18:46:41.7230470Z - request: body: null headers: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:12 GMT + - Fri, 04 Sep 2020 18:46:42 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=bad_version_id + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-21T21:24:15.3585832Z response: body: string: '' headers: - date: Tue, 01 Sep 2020 02:21:11 GMT + date: Fri, 04 Sep 2020 18:46:42 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-ms-error-code: BlobNotFound + x-ms-version: '2019-12-12' status: - code: 400 - message: Value for one of the query parameters specified in the request URI - is invalid. - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=bad_version_id + code: 404 + message: The specified blob does not exist. + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?versionid=2020-08-21T21:24:15.3585832Z - request: body: null headers: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:13 GMT + - Fri, 04 Sep 2020 18:46:43 GMT x-ms-version: - '2019-12-12' method: PUT @@ -303,14 +305,14 @@ interactions: string: '' headers: content-length: '0' - date: Tue, 01 Sep 2020 02:21:12 GMT - etag: '"0x8D84E1DB11D3302"' - last-modified: Tue, 01 Sep 2020 02:21:10 GMT + date: Fri, 04 Sep 2020 18:46:42 GMT + etag: '"0x8D85102DD486B76"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-server-encrypted: 'false' - x-ms-snapshot: '2020-09-01T02:21:13.4454804Z' + x-ms-snapshot: '2020-09-04T18:46:43.1560641Z' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:13.4464804Z' + x-ms-version-id: '2020-09-04T18:46:43.1570641Z' status: code: 201 message: Created @@ -321,11 +323,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:14 GMT + - Fri, 04 Sep 2020 18:46:43 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-01T02:21:13.4454804Z + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-04T18:46:43.1560641Z response: body: string: '' @@ -333,20 +335,20 @@ interactions: accept-ranges: bytes content-length: '20' content-type: application/octet-stream - date: Tue, 01 Sep 2020 02:21:13 GMT - etag: '"0x8D84E1DB11D3302"' - last-modified: Tue, 01 Sep 2020 02:21:10 GMT + date: Fri, 04 Sep 2020 18:46:42 GMT + etag: '"0x8D85102DD486B76"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Tue, 01 Sep 2020 02:21:10 GMT + x-ms-creation-time: Fri, 04 Sep 2020 18:46:41 GMT x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' status: code: 200 message: OK - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-01T02:21:13.4454804Z + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-04T18:46:43.1560641Z - request: body: this is additional test content headers: @@ -357,7 +359,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:14 GMT + - Fri, 04 Sep 2020 18:46:43 GMT x-ms-version: - '2019-12-12' method: PUT @@ -367,7 +369,7 @@ interactions: string: '' headers: content-length: '0' - date: Tue, 01 Sep 2020 02:21:13 GMT + date: Fri, 04 Sep 2020 18:46:42 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: npKkArwnhSg= x-ms-request-server-encrypted: 'true' @@ -388,7 +390,7 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:15 GMT + - Fri, 04 Sep 2020 18:46:44 GMT x-ms-version: - '2019-12-12' method: PUT @@ -398,14 +400,14 @@ interactions: string: '' headers: content-length: '0' - date: Tue, 01 Sep 2020 02:21:13 GMT - etag: '"0x8D84E1DB37328BC"' - last-modified: Tue, 01 Sep 2020 02:21:14 GMT + date: Fri, 04 Sep 2020 18:46:42 GMT + etag: '"0x8D85102DE756263"' + last-modified: Fri, 04 Sep 2020 18:46:43 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-content-crc64: iEgKfcNWGmY= x-ms-request-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:14.4622028Z' + x-ms-version-id: '2020-09-04T18:46:43.6954483Z' status: code: 201 message: Created @@ -416,11 +418,11 @@ interactions: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:15 GMT + - Fri, 04 Sep 2020 18:46:44 GMT x-ms-version: - '2019-12-12' method: HEAD - uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-01T02:21:13.4454804Z + uri: https://storagename.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-04T18:46:43.1560641Z response: body: string: '' @@ -428,27 +430,27 @@ interactions: accept-ranges: bytes content-length: '20' content-type: application/octet-stream - date: Tue, 01 Sep 2020 02:21:14 GMT - etag: '"0x8D84E1DB11D3302"' - last-modified: Tue, 01 Sep 2020 02:21:10 GMT + date: Fri, 04 Sep 2020 18:46:42 GMT + etag: '"0x8D85102DD486B76"' + last-modified: Fri, 04 Sep 2020 18:46:41 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Tue, 01 Sep 2020 02:21:10 GMT + x-ms-creation-time: Fri, 04 Sep 2020 18:46:41 GMT x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' status: code: 200 message: OK - url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-01T02:21:13.4454804Z + url: https://tamerdevtest.blob.core.windows.net/utcontainer4a2315bf/blob1?snapshot=2020-09-04T18:46:43.1560641Z - request: body: null headers: User-Agent: - azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0) x-ms-date: - - Tue, 01 Sep 2020 02:21:15 GMT + - Fri, 04 Sep 2020 18:46:44 GMT x-ms-version: - '2019-12-12' method: HEAD @@ -460,20 +462,20 @@ interactions: accept-ranges: bytes content-length: '31' content-type: application/octet-stream - date: Tue, 01 Sep 2020 02:21:14 GMT - etag: '"0x8D84E1DB37328BC"' - last-modified: Tue, 01 Sep 2020 02:21:14 GMT + date: Fri, 04 Sep 2020 18:46:43 GMT + etag: '"0x8D85102DE756263"' + last-modified: Fri, 04 Sep 2020 18:46:43 GMT server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-access-tier: Hot x-ms-access-tier-inferred: 'true' x-ms-blob-type: BlockBlob - x-ms-creation-time: Tue, 01 Sep 2020 02:21:14 GMT + x-ms-creation-time: Fri, 04 Sep 2020 18:46:43 GMT x-ms-is-current-version: 'true' x-ms-lease-state: available x-ms-lease-status: unlocked x-ms-server-encrypted: 'true' x-ms-version: '2019-12-12' - x-ms-version-id: '2020-09-01T02:21:14.4622028Z' + x-ms-version-id: '2020-09-04T18:46:43.6954483Z' status: code: 200 message: OK diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py index 3b6b6eacf700..b353b5fa0b16 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py @@ -764,7 +764,7 @@ async def test_if_blob_exists(self, resource_group, location, storage_account, s # Assert self.assertEqual(await blob.exists(version_id=old_blob_version_id), True) self.assertEqual(await blob.exists(version_id=new_blob_version_id), True) - self.assertEqual(await blob.exists(version_id="bad_version_id"), False) + self.assertEqual(await blob.exists(version_id="2020-08-21T21:24:15.3585832Z"), False) # Act test_snapshot = await blob.create_snapshot() From bd091a5cda456d13b72240b7ad3767115169e070 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Fri, 4 Sep 2020 13:46:54 -0700 Subject: [PATCH 11/11] fixed linting/import order --- .../azure-storage-blob/azure/storage/blob/_blob_client.py | 2 +- .../azure/storage/blob/aio/_blob_client_async.py | 2 +- 2 files changed, 2 insertions(+), 2 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 aee5b9681cf9..3390840d9203 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 @@ -18,6 +18,7 @@ import six from azure.core.tracing.decorator import distributed_trace +from azure.core.exceptions import ResourceNotFoundError from ._shared import encode_base64 from ._shared.base_client import StorageAccountHostsMixin, parse_connection_str, parse_query @@ -54,7 +55,6 @@ upload_page_blob) from ._models import BlobType, BlobBlock, BlobProperties, BlobQueryError from ._download import StorageStreamDownloader -from azure.core.exceptions import ResourceNotFoundError from ._lease import BlobLeaseClient if TYPE_CHECKING: 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 a5ef0d0e82ef..49674227f6de 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 @@ -11,6 +11,7 @@ ) from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.exceptions import ResourceNotFoundError from .._shared.base_client_async import AsyncStorageAccountHostsMixin from .._shared.policies_async import ExponentialRetry @@ -29,7 +30,6 @@ from .._models import BlobType, BlobBlock, BlobProperties from ._lease_async import BlobLeaseClient from ._download_async import StorageStreamDownloader -from azure.core.exceptions import ResourceNotFoundError if TYPE_CHECKING: