From d67af2b766c79713a52b6cd0a9c94839abd042c5 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Fri, 12 Feb 2021 16:16:21 -0800 Subject: [PATCH 1/4] Added exists() to Datalake clients --- .../_data_lake_directory_client.py | 18 +++++++++++++++--- .../filedatalake/_data_lake_file_client.py | 17 ++++++++++++++--- .../filedatalake/_file_system_client.py | 13 ++++++++++++- .../azure/storage/filedatalake/_path_client.py | 17 ++++++++++++++--- .../aio/_data_lake_directory_client_async.py | 13 +++++++++++++ .../aio/_data_lake_file_client_async.py | 17 ++++++++++++++--- .../aio/_file_system_client_async.py | 13 +++++++++++++ .../filedatalake/aio/_path_client_async.py | 18 +++++++++++++++--- 8 files changed, 110 insertions(+), 16 deletions(-) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py index b46c43d761b4..22eefba76055 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py @@ -3,6 +3,8 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from typing import Any + try: from urllib.parse import quote, unquote except ImportError: @@ -241,9 +243,19 @@ def get_directory_properties(self, **kwargs): """ return self._get_path_properties(cls=deserialize_dir_properties, **kwargs) # pylint: disable=protected-access - def rename_directory(self, new_name, # type: str - **kwargs): - # type: (**Any) -> DataLakeDirectoryClient + def exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a directory exists and returns False otherwise. + + :kwarg int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + return self._exists(**kwargs) + + def rename_directory(self, new_name, **kwargs): + # type: (str, **Any) -> DataLakeDirectoryClient """ Rename the source directory. diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py index d314712109c0..0a452c189603 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py @@ -4,6 +4,7 @@ # license information. # -------------------------------------------------------------------------- from io import BytesIO +from typing import Any try: from urllib.parse import quote, unquote @@ -596,9 +597,19 @@ def download_file(self, offset=None, length=None, **kwargs): downloader = self._blob_client.download_blob(offset=offset, length=length, **kwargs) return StorageStreamDownloader(downloader) - def rename_file(self, new_name, # type: str - **kwargs): - # type: (**Any) -> DataLakeFileClient + def exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a file exists and returns False otherwise. + + :kwarg int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + return self._exists(**kwargs) + + def rename_file(self, new_name, **kwargs): + # type: (str, **Any) -> DataLakeFileClient """ Rename the source file. diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py index 6f5f72ad9a18..0c0fbc36673e 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from typing import Optional +from typing import Optional, Any try: from urllib.parse import urlparse, quote @@ -247,6 +247,17 @@ def create_file_system(self, metadata=None, # type: Optional[Dict[str, str]] public_access=public_access, **kwargs) + def exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a file system exists and returns False otherwise. + + :kwarg int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + return self._container_client.exists(**kwargs) + def _rename_file_system(self, new_name, **kwargs): # type: (str, **Any) -> FileSystemClient """Renames a filesystem. diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py index ba2425f5c13d..cdbe9a771bba 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py @@ -11,6 +11,7 @@ from urllib2 import quote # type: ignore import six +from typing import Any, Dict from azure.core.exceptions import AzureError, HttpResponseError from azure.storage.blob import BlobClient @@ -657,9 +658,8 @@ def _rename_path_options(self, rename_source, content_settings=None, metadata=No options.update(kwargs) return options - def _rename_path(self, rename_source, - **kwargs): - # type: (**Any) -> Dict[str, Any] + def _rename_path(self, rename_source, **kwargs): + # type: (str, **Any) -> Dict[str, Any] """ Rename directory or file @@ -764,6 +764,17 @@ def _get_path_properties(self, **kwargs): path_properties = self._blob_client.get_blob_properties(**kwargs) return path_properties + def _exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a path exists and returns False otherwise. + + :kwarg int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + return self._blob_client.exists(**kwargs) + def set_metadata(self, metadata, # type: Dict[str, str] **kwargs): # type: (...) -> Dict[str, Union[str, datetime]] diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py index 23b26feea82c..6fbe94a4c593 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py @@ -4,6 +4,8 @@ # license information. # -------------------------------------------------------------------------- # pylint: disable=invalid-overridden-method +from typing import Any + try: from urllib.parse import quote, unquote except ImportError: @@ -128,6 +130,17 @@ async def create_directory(self, metadata=None, # type: Optional[Dict[str, str] """ return await self._create('directory', metadata=metadata, **kwargs) + async def exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a directory exists and returns False otherwise. + + :kwarg int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + return await self._exists(**kwargs) + async def delete_directory(self, **kwargs): # type: (...) -> None """ diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py index 9bbc7c267149..4f57267540fb 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py @@ -6,6 +6,7 @@ # pylint: disable=invalid-overridden-method from azure.core.exceptions import HttpResponseError +from typing import Any try: from urllib.parse import quote, unquote except ImportError: @@ -130,6 +131,17 @@ async def create_file(self, content_settings=None, # type: Optional[ContentSett """ return await self._create('file', content_settings=content_settings, metadata=metadata, **kwargs) + async def exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a file exists and returns False otherwise. + + :kwarg int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + return await self._exists(**kwargs) + async def delete_file(self, **kwargs): # type: (...) -> None """ @@ -461,9 +473,8 @@ async def download_file(self, offset=None, length=None, **kwargs): downloader = await self._blob_client.download_blob(offset=offset, length=length, **kwargs) return StorageStreamDownloader(downloader) - async def rename_file(self, new_name, # type: str - **kwargs): - # type: (**Any) -> DataLakeFileClient + async def rename_file(self, new_name, **kwargs): + # type: (str, **Any) -> DataLakeFileClient """ Rename the source file. diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py index 1ef4d4791940..108fc1817046 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py @@ -193,6 +193,19 @@ async def create_file_system(self, metadata=None, # type: Optional[Dict[str, st return await self._container_client.create_container(metadata=metadata, public_access=public_access, **kwargs) + + @distributed_trace_async + async def exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a file system exists and returns False otherwise. + + :kwarg int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + return await self._container_client.exists(**kwargs) + @distributed_trace_async async def _rename_file_system(self, new_name, **kwargs): # type: (str, **Any) -> FileSystemClient diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py index 99f1eff10051..43537ec532cc 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py @@ -4,6 +4,8 @@ # license information. # -------------------------------------------------------------------------- # pylint: disable=invalid-overridden-method +from typing import Any, Dict + from azure.core.exceptions import AzureError, HttpResponseError from azure.storage.blob.aio import BlobClient from .._shared.base_client_async import AsyncStorageAccountHostsMixin @@ -489,9 +491,8 @@ async def _set_access_control_internal(self, options, progress_hook, max_batches error.continuation_token = last_continuation_token raise error - async def _rename_path(self, rename_source, - **kwargs): - # type: (**Any) -> Dict[str, Any] + async def _rename_path(self, rename_source, **kwargs): + # type: (str, **Any) -> Dict[str, Any] """ Rename directory or file @@ -585,6 +586,17 @@ async def _get_path_properties(self, **kwargs): path_properties = await self._blob_client.get_blob_properties(**kwargs) return path_properties + async def _exists(self, **kwargs): + # type: (**Any) -> bool + """ + Returns True if a path exists and returns False otherwise. + + :kwarg int timeout: + The timeout parameter is expressed in seconds. + :returns: boolean + """ + return await self._blob_client.exists(**kwargs) + async def set_metadata(self, metadata, # type: Dict[str, str] **kwargs): # type: (...) -> Dict[str, Union[str, datetime]] From c3424a447b5a23aaf4d0ee3e76e61cead608d1e2 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Fri, 12 Feb 2021 16:58:49 -0800 Subject: [PATCH 2/4] added tests --- .../test_directory.test_directory_exists.yaml | 154 ++++++++++++++ ...directory_async.test_directory_exists.yaml | 110 ++++++++++ .../test_file.test_file_exists.yaml | 196 ++++++++++++++++++ .../test_file_async.test_file_exists.yaml | 141 +++++++++++++ ...t_file_system.test_file_system_exists.yaml | 137 ++++++++++++ ..._system_async.test_file_system_exists.yaml | 99 +++++++++ .../tests/test_directory.py | 12 ++ .../tests/test_directory_async.py | 16 ++ .../tests/test_file.py | 15 ++ .../tests/test_file_async.py | 19 ++ .../tests/test_file_system.py | 13 ++ .../tests/test_file_system_async.py | 17 ++ 12 files changed, 929 insertions(+) create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory.test_directory_exists.yaml create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory_async.test_directory_exists.yaml create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file.test_file_exists.yaml create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_async.test_file_exists.yaml create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_file_system_exists.yaml create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_file_system_exists.yaml diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory.test_directory_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory.test_directory_exists.yaml new file mode 100644 index 000000000000..59b7c23c1def --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory.test_directory_exists.yaml @@ -0,0 +1,154 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 9a927806-6d95-11eb-88b1-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:51:27 GMT + x-ms-properties: + - '' + x-ms-version: + - '2020-02-10' + method: PUT + uri: https://storagename.dfs.core.windows.net/filesystem14f20f16/directory14f20f16?resource=directory + response: + body: + string: '' + headers: + Content-Length: + - '0' + Date: + - Sat, 13 Feb 2021 00:51:27 GMT + ETag: + - '"0x8D8CFB97F049139"' + Last-Modified: + - Sat, 13 Feb 2021 00:51:27 GMT + Server: + - Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-id: + - fb56c3de-d01f-0087-30a2-015939000000 + x-ms-version: + - '2020-02-10' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 9ad1ad3c-6d95-11eb-83fe-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:51:27 GMT + x-ms-encryption-algorithm: + - AES256 + x-ms-version: + - '2020-06-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/filesystem14f20f16/directory14f20f16 + response: + body: + string: '' + headers: + Accept-Ranges: + - bytes + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Sat, 13 Feb 2021 00:51:29 GMT + ETag: + - '"0x8D8CFB97F049139"' + Last-Modified: + - Sat, 13 Feb 2021 00:51:27 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: + - Sat, 13 Feb 2021 00:51:27 GMT + x-ms-group: + - $superuser + x-ms-lease-state: + - available + x-ms-lease-status: + - unlocked + x-ms-meta-hdi_isfolder: + - 'true' + x-ms-owner: + - $superuser + x-ms-permissions: + - rwxr-x--- + x-ms-request-id: + - b4f7c70a-a01e-0079-4ea2-013678000000 + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2020-06-12' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 9bdb1e09-6d95-11eb-8209-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:51:29 GMT + x-ms-encryption-algorithm: + - AES256 + x-ms-version: + - '2020-06-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/filesystem14f20f16/baddirectory + response: + body: + string: '' + headers: + Date: + - Sat, 13 Feb 2021 00:51:29 GMT + Server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + Transfer-Encoding: + - chunked + x-ms-error-code: + - BlobNotFound + x-ms-request-id: + - b4f7c93c-a01e-0079-7ea2-013678000000 + x-ms-version: + - '2020-06-12' + status: + code: 404 + message: The specified blob does not exist. +version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory_async.test_directory_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory_async.test_directory_exists.yaml new file mode 100644 index 000000000000..1117759fed97 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory_async.test_directory_exists.yaml @@ -0,0 +1,110 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 9c0a3899-6d96-11eb-97ca-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:58:39 GMT + x-ms-properties: + - '' + x-ms-version: + - '2020-02-10' + method: PUT + uri: https://storagename.dfs.core.windows.net/filesystem78031193/directory78031193?resource=directory + response: + body: + string: '' + headers: + Content-Length: '0' + Date: Sat, 13 Feb 2021 00:58:39 GMT + ETag: '"0x8D8CFBA80688D7E"' + Last-Modified: Sat, 13 Feb 2021 00:58:39 GMT + Server: Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-id: 53966198-b01f-0017-40a3-016357000000 + x-ms-version: '2020-02-10' + status: + code: 201 + message: Created + url: https://seanprodhierarchical.dfs.core.windows.net/filesystem78031193/directory78031193?resource=directory +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 9c380c49-6d96-11eb-8d8e-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:58:39 GMT + x-ms-encryption-algorithm: + - AES256 + x-ms-version: + - '2020-06-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/filesystem78031193/directory78031193 + response: + body: + string: '' + headers: + Accept-Ranges: bytes + Content-Length: '0' + Content-Type: application/octet-stream + Date: Sat, 13 Feb 2021 00:58:39 GMT + ETag: '"0x8D8CFBA80688D7E"' + Last-Modified: Sat, 13 Feb 2021 00:58:39 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: Sat, 13 Feb 2021 00:58:39 GMT + x-ms-group: $superuser + x-ms-lease-state: available + x-ms-lease-status: unlocked + x-ms-meta-hdi_isfolder: 'true' + x-ms-owner: $superuser + x-ms-permissions: rwxr-x--- + x-ms-request-id: 99d7f49a-601e-00df-53a3-018166000000 + x-ms-server-encrypted: 'true' + x-ms-version: '2020-06-12' + status: + code: 200 + message: OK + url: https://seanprodhierarchical.blob.core.windows.net/filesystem78031193/directory78031193 +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 9c3af273-6d96-11eb-add2-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:58:39 GMT + x-ms-encryption-algorithm: + - AES256 + x-ms-version: + - '2020-06-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/filesystem78031193/baddirectory + response: + body: + string: '' + headers: + Date: Sat, 13 Feb 2021 00:58:39 GMT + Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + Transfer-Encoding: chunked + x-ms-error-code: BlobNotFound + x-ms-request-id: 99d7f49f-601e-00df-57a3-018166000000 + x-ms-version: '2020-06-12' + status: + code: 404 + message: The specified blob does not exist. + url: https://seanprodhierarchical.blob.core.windows.net/filesystem78031193/baddirectory +version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file.test_file_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file.test_file_exists.yaml new file mode 100644 index 000000000000..c263a09eb3cb --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file.test_file_exists.yaml @@ -0,0 +1,196 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 8b3c6806-6d94-11eb-8ce0-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:43:52 GMT + x-ms-properties: + - '' + x-ms-version: + - '2020-02-10' + method: PUT + uri: https://storagename.dfs.core.windows.net/filesystem8ebf0aac/directory8ebf0aac?resource=directory + response: + body: + string: '' + headers: + Content-Length: + - '0' + Date: + - Sat, 13 Feb 2021 00:43:51 GMT + ETag: + - '"0x8D8CFB86FA2ADD0"' + Last-Modified: + - Sat, 13 Feb 2021 00:43:52 GMT + Server: + - Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-id: + - a55bcdb1-901f-00db-42a1-010c61000000 + x-ms-version: + - '2020-02-10' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 8b6e509d-6d94-11eb-a8ab-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:43:52 GMT + x-ms-properties: + - '' + x-ms-version: + - '2020-02-10' + method: PUT + uri: https://storagename.dfs.core.windows.net/filesystem8ebf0aac/directory8ebf0aac%2Ffilename?resource=file + response: + body: + string: '' + headers: + Content-Length: + - '0' + Date: + - Sat, 13 Feb 2021 00:43:52 GMT + ETag: + - '"0x8D8CFB86FAF6634"' + Last-Modified: + - Sat, 13 Feb 2021 00:43:52 GMT + Server: + - Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-id: + - a55bcdb9-901f-00db-4aa1-010c61000000 + x-ms-version: + - '2020-02-10' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 8b7afa0e-6d94-11eb-b96b-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:43:52 GMT + x-ms-encryption-algorithm: + - AES256 + x-ms-version: + - '2020-06-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/filesystem8ebf0aac/directory8ebf0aac/filename + response: + body: + string: '' + headers: + Accept-Ranges: + - bytes + Content-Length: + - '0' + Content-Type: + - application/octet-stream + Date: + - Sat, 13 Feb 2021 00:43:52 GMT + ETag: + - '"0x8D8CFB86FAF6634"' + Last-Modified: + - Sat, 13 Feb 2021 00:43:52 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: + - Sat, 13 Feb 2021 00:43:52 GMT + x-ms-group: + - $superuser + x-ms-lease-state: + - available + x-ms-lease-status: + - unlocked + x-ms-owner: + - $superuser + x-ms-permissions: + - rw-r----- + x-ms-request-id: + - 430eeb87-701e-008e-3ba1-011cea000000 + x-ms-server-encrypted: + - 'true' + x-ms-version: + - '2020-06-12' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 8ba2cd58-6d94-11eb-8c8b-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:43:53 GMT + x-ms-encryption-algorithm: + - AES256 + x-ms-version: + - '2020-06-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/filesystem8ebf0aac/directory8ebf0aac/badfilename + response: + body: + string: '' + headers: + Date: + - Sat, 13 Feb 2021 00:43:52 GMT + Server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + Transfer-Encoding: + - chunked + x-ms-error-code: + - BlobNotFound + x-ms-request-id: + - 430eebc7-701e-008e-73a1-011cea000000 + x-ms-version: + - '2020-06-12' + status: + code: 404 + message: The specified blob does not exist. +version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_async.test_file_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_async.test_file_exists.yaml new file mode 100644 index 000000000000..b05e918ee1e5 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_async.test_file_exists.yaml @@ -0,0 +1,141 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - efaedac6-6d95-11eb-9bc1-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:53:50 GMT + x-ms-properties: + - '' + x-ms-version: + - '2020-02-10' + method: PUT + uri: https://storagename.dfs.core.windows.net/filesystemd8210d29/directoryd8210d29?resource=directory + response: + body: + string: '' + headers: + Content-Length: '0' + Date: Sat, 13 Feb 2021 00:53:49 GMT + ETag: '"0x8D8CFB9D41CFDA5"' + Last-Modified: Sat, 13 Feb 2021 00:53:50 GMT + Server: Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-id: 55a13272-a01f-009d-80a2-0138e6000000 + x-ms-version: '2020-02-10' + status: + code: 201 + message: Created + url: https://seanprodhierarchical.dfs.core.windows.net/filesystemd8210d29/directoryd8210d29?resource=directory +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - efe889a0-6d95-11eb-bda1-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:53:50 GMT + x-ms-properties: + - '' + x-ms-version: + - '2020-02-10' + method: PUT + uri: https://storagename.dfs.core.windows.net/filesystemd8210d29/directoryd8210d29%2Ffilename?resource=file + response: + body: + string: '' + headers: + Content-Length: '0' + Date: Sat, 13 Feb 2021 00:53:49 GMT + ETag: '"0x8D8CFB9D420F58B"' + Last-Modified: Sat, 13 Feb 2021 00:53:50 GMT + Server: Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-id: 55a13276-a01f-009d-04a2-0138e6000000 + x-ms-version: '2020-02-10' + status: + code: 201 + message: Created + url: https://seanprodhierarchical.dfs.core.windows.net/filesystemd8210d29/directoryd8210d29%2Ffilename?resource=file +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - efec3311-6d95-11eb-968f-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:53:50 GMT + x-ms-encryption-algorithm: + - AES256 + x-ms-version: + - '2020-06-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/filesystemd8210d29/directoryd8210d29/filename + response: + body: + string: '' + headers: + Accept-Ranges: bytes + Content-Length: '0' + Content-Type: application/octet-stream + Date: Sat, 13 Feb 2021 00:53:50 GMT + ETag: '"0x8D8CFB9D420F58B"' + Last-Modified: Sat, 13 Feb 2021 00:53:50 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: Sat, 13 Feb 2021 00:53:50 GMT + x-ms-group: $superuser + x-ms-lease-state: available + x-ms-lease-status: unlocked + x-ms-owner: $superuser + x-ms-permissions: rw-r----- + x-ms-request-id: 266f3dd6-a01e-00a2-34a2-01f045000000 + x-ms-server-encrypted: 'true' + x-ms-version: '2020-06-12' + status: + code: 200 + message: OK + url: https://seanprodhierarchical.blob.core.windows.net/filesystemd8210d29/directoryd8210d29/filename +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - efef6773-6d95-11eb-8bf7-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:53:50 GMT + x-ms-encryption-algorithm: + - AES256 + x-ms-version: + - '2020-06-12' + method: HEAD + uri: https://storagename.blob.core.windows.net/filesystemd8210d29/directoryd8210d29/badfilename + response: + body: + string: '' + headers: + Date: Sat, 13 Feb 2021 00:53:50 GMT + Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + Transfer-Encoding: chunked + x-ms-error-code: BlobNotFound + x-ms-request-id: 266f3dda-a01e-00a2-38a2-01f045000000 + x-ms-version: '2020-06-12' + status: + code: 404 + message: The specified blob does not exist. + url: https://seanprodhierarchical.blob.core.windows.net/filesystemd8210d29/directoryd8210d29/badfilename +version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_file_system_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_file_system_exists.yaml new file mode 100644 index 000000000000..d2691e18375e --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_file_system_exists.yaml @@ -0,0 +1,137 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 163422c3-6d95-11eb-853a-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:47:45 GMT + x-ms-version: + - '2020-06-12' + method: PUT + uri: https://storagename.blob.core.windows.net/filesystem545310b4?restype=container + response: + body: + string: '' + headers: + Content-Length: + - '0' + Date: + - Sat, 13 Feb 2021 00:47:46 GMT + ETag: + - '"0x8D8CFB8FAA5592A"' + Last-Modified: + - Sat, 13 Feb 2021 00:47:45 GMT + Server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-id: + - 7b6e01d3-401e-002c-28a1-0126f3000000 + x-ms-version: + - '2020-06-12' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 16db2a0b-6d95-11eb-9edd-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:47:46 GMT + x-ms-version: + - '2020-06-12' + method: GET + uri: https://storagename.blob.core.windows.net/filesystem545310b4?restype=container + response: + body: + string: '' + headers: + Content-Length: + - '0' + Date: + - Sat, 13 Feb 2021 00:47:46 GMT + ETag: + - '"0x8D8CFB8FAA5592A"' + Last-Modified: + - Sat, 13 Feb 2021 00:47:45 GMT + Server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-default-encryption-scope: + - $account-encryption-key + x-ms-deny-encryption-scope-override: + - 'false' + x-ms-has-immutability-policy: + - 'false' + x-ms-has-legal-hold: + - 'false' + x-ms-lease-state: + - available + x-ms-lease-status: + - unlocked + x-ms-request-id: + - 7b6e03b5-401e-002c-3da1-0126f3000000 + x-ms-version: + - '2020-06-12' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/xml + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 16e52cde-6d95-11eb-9127-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:47:46 GMT + x-ms-version: + - '2020-06-12' + method: GET + uri: https://storagename.blob.core.windows.net/badfilesystem?restype=container + response: + body: + string: "\uFEFFContainerNotFoundThe + specified container does not exist.\nRequestId:7b6e03dc-401e-002c-5ea1-0126f3000000\nTime:2021-02-13T00:47:46.7353500Z" + headers: + Content-Length: + - '225' + Content-Type: + - application/xml + Date: + - Sat, 13 Feb 2021 00:47:46 GMT + Server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-error-code: + - ContainerNotFound + x-ms-request-id: + - 7b6e03dc-401e-002c-5ea1-0126f3000000 + x-ms-version: + - '2020-06-12' + status: + code: 404 + message: The specified container does not exist. +version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_file_system_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_file_system_exists.yaml new file mode 100644 index 000000000000..b969818d3a79 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_file_system_exists.yaml @@ -0,0 +1,99 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 5c494251-6d96-11eb-97fd-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:56:52 GMT + x-ms-version: + - '2020-06-12' + method: PUT + uri: https://storagename.blob.core.windows.net/filesystemc1381331?restype=container + response: + body: + string: '' + headers: + Content-Length: '0' + Date: Sat, 13 Feb 2021 00:56:53 GMT + ETag: '"0x8D8CFBA40A850D8"' + Last-Modified: Sat, 13 Feb 2021 00:56:52 GMT + Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-request-id: d2c68460-901e-0000-50a3-01ca5c000000 + x-ms-version: '2020-06-12' + status: + code: 201 + message: Created + url: https://seanprodhierarchical.blob.core.windows.net/filesystemc1381331?restype=container +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 5d160a32-6d96-11eb-955b-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:56:53 GMT + x-ms-version: + - '2020-06-12' + method: GET + uri: https://storagename.blob.core.windows.net/filesystemc1381331?restype=container + response: + body: + string: '' + headers: + Content-Length: '0' + Date: Sat, 13 Feb 2021 00:56:53 GMT + ETag: '"0x8D8CFBA40A850D8"' + Last-Modified: Sat, 13 Feb 2021 00:56:52 GMT + Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-default-encryption-scope: $account-encryption-key + x-ms-deny-encryption-scope-override: 'false' + x-ms-has-immutability-policy: 'false' + x-ms-has-legal-hold: 'false' + x-ms-lease-state: available + x-ms-lease-status: unlocked + x-ms-request-id: d2c686a6-901e-0000-12a3-01ca5c000000 + x-ms-version: '2020-06-12' + status: + code: 200 + message: OK + url: https://seanprodhierarchical.blob.core.windows.net/filesystemc1381331?restype=container +- request: + body: null + headers: + Accept: + - application/xml + User-Agent: + - azsdk-python-storage-dfs/12.3.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0) + x-ms-client-request-id: + - 5d191774-6d96-11eb-a4ac-c8348e5fffbf + x-ms-date: + - Sat, 13 Feb 2021 00:56:53 GMT + x-ms-version: + - '2020-06-12' + method: GET + uri: https://storagename.blob.core.windows.net/badfilesystem?restype=container + response: + body: + string: "\uFEFFContainerNotFoundThe + specified container does not exist.\nRequestId:d2c686af-901e-0000-18a3-01ca5c000000\nTime:2021-02-13T00:56:53.9582341Z" + headers: + Content-Length: '225' + Content-Type: application/xml + Date: Sat, 13 Feb 2021 00:56:53 GMT + Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + x-ms-error-code: ContainerNotFound + x-ms-request-id: d2c686af-901e-0000-18a3-01ca5c000000 + x-ms-version: '2020-06-12' + status: + code: 404 + message: The specified container does not exist. + url: https://seanprodhierarchical.blob.core.windows.net/badfilesystem?restype=container +version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_directory.py b/sdk/storage/azure-storage-file-datalake/tests/test_directory.py index 221098d61393..5bdb97ec4ec7 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_directory.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_directory.py @@ -97,6 +97,18 @@ def test_create_directory(self): # Assert self.assertTrue(created) + @record + def test_directory_exists(self): + # Arrange + directory_name = self._get_directory_reference() + + directory_client1 = self.dsc.get_directory_client(self.file_system_name, directory_name) + directory_client2 = self.dsc.get_directory_client(self.file_system_name, "baddirectory") + directory_client1.create_directory() + + self.assertTrue(directory_client1.exists()) + self.assertFalse(directory_client2.exists()) + @record def test_using_oauth_token_credential_to_create_directory(self): # generate a token with directory level create permission diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_directory_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_directory_async.py index 09074b37ca31..8ea57e604efb 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_directory_async.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_directory_async.py @@ -123,6 +123,22 @@ def test_create_directory_async(self): loop = asyncio.get_event_loop() loop.run_until_complete(self._test_create_directory()) + async def _test_directory_exists(self): + # Arrange + directory_name = self._get_directory_reference() + + directory_client1 = self.dsc.get_directory_client(self.file_system_name, directory_name) + directory_client2 = self.dsc.get_directory_client(self.file_system_name, "baddirectory") + await directory_client1.create_directory() + + self.assertTrue(await directory_client1.exists()) + self.assertFalse(await directory_client2.exists()) + + @record + def test_directory_exists(self): + loop = asyncio.get_event_loop() + loop.run_until_complete(self._test_directory_exists()) + async def _test_using_oauth_token_credential_to_create_directory(self): # generate a token with directory level create permission directory_name = self._get_directory_reference() diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file.py b/sdk/storage/azure-storage-file-datalake/tests/test_file.py index 80ddebad1f55..ee7f0e635562 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file.py @@ -101,6 +101,21 @@ def test_create_file(self): # Assert self.assertIsNotNone(response) + @record + def test_file_exists(self): + # Arrange + directory_name = self._get_directory_reference() + + directory_client = self.dsc.get_directory_client(self.file_system_name, directory_name) + directory_client.create_directory() + + file_client1 = directory_client.get_file_client('filename') + file_client2 = directory_client.get_file_client('badfilename') + file_client1.create_file() + + self.assertTrue(file_client1.exists()) + self.assertFalse(file_client2.exists()) + @record def test_create_file_using_oauth_token_credential(self): # Arrange diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py index a0f03141ecf1..8f4af97d3e6a 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py @@ -114,6 +114,25 @@ def test_create_file_async(self): loop = asyncio.get_event_loop() loop.run_until_complete(self._test_create_file()) + async def _test_file_exists(self): + # Arrange + directory_name = self._get_directory_reference() + + directory_client = self.dsc.get_directory_client(self.file_system_name, directory_name) + await directory_client.create_directory() + + file_client1 = directory_client.get_file_client('filename') + file_client2 = directory_client.get_file_client('badfilename') + await file_client1.create_file() + + self.assertTrue(await file_client1.exists()) + self.assertFalse(await file_client2.exists()) + + @record + def test_file_exists(self): + loop = asyncio.get_event_loop() + loop.run_until_complete(self._test_file_exists()) + async def _test_create_file_using_oauth_token_credential(self): # Arrange file_name = self._get_file_reference() diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py index 4e03b021079b..f4685d617df0 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py @@ -70,6 +70,19 @@ def test_create_file_system(self): # Assert self.assertTrue(created) + @record + def test_file_system_exists(self): + # Arrange + file_system_name = self._get_file_system_reference() + + # Act + file_system_client1 = self.dsc.get_file_system_client(file_system_name) + file_system_client2 = self.dsc.get_file_system_client("badfilesystem") + file_system_client1.create_file_system() + + self.assertTrue(file_system_client1.exists()) + self.assertFalse(file_system_client2.exists()) + @record def test_create_file_system_with_metadata(self): # Arrange diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py index 608b9e5984e9..02edca6c6a36 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py @@ -96,6 +96,23 @@ def test_create_file_system_async(self): loop = asyncio.get_event_loop() loop.run_until_complete(self._test_create_file_system_async()) + async def _test_file_system_exists(self): + # Arrange + file_system_name = self._get_file_system_reference() + + # Act + file_system_client1 = self.dsc.get_file_system_client(file_system_name) + file_system_client2 = self.dsc.get_file_system_client("badfilesystem") + await file_system_client1.create_file_system() + + self.assertTrue(await file_system_client1.exists()) + self.assertFalse(await file_system_client2.exists()) + + @record + def test_file_system_exists(self): + loop = asyncio.get_event_loop() + loop.run_until_complete(self._test_file_system_exists()) + async def _test_create_file_system_with_metadata_async(self): # Arrange metadata = {'hello': 'world', 'number': '42'} From edfe2633613c515777fe22e5cf013994661f9cd5 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Fri, 12 Feb 2021 19:41:26 -0800 Subject: [PATCH 3/4] linter --- .../azure/storage/filedatalake/_path_client.py | 2 +- .../storage/filedatalake/aio/_data_lake_file_client_async.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py index cdbe9a771bba..fcc7c715dfa2 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from typing import Any, Dict try: from urllib.parse import urlparse, quote @@ -11,7 +12,6 @@ from urllib2 import quote # type: ignore import six -from typing import Any, Dict from azure.core.exceptions import AzureError, HttpResponseError from azure.storage.blob import BlobClient diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py index 4f57267540fb..34532c94eafd 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py @@ -4,14 +4,13 @@ # license information. # -------------------------------------------------------------------------- # pylint: disable=invalid-overridden-method -from azure.core.exceptions import HttpResponseError - from typing import Any try: from urllib.parse import quote, unquote except ImportError: from urllib2 import quote, unquote # type: ignore +from azure.core.exceptions import HttpResponseError from ._download_async import StorageStreamDownloader from ._path_client_async import PathClient from .._data_lake_file_client import DataLakeFileClient as DataLakeFileClientBase From cd597b9f2c10000b03a5305520dd692f5c004b36 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Tue, 16 Feb 2021 13:30:33 -0800 Subject: [PATCH 4/4] fixed test name --- .../recordings/test_directory.test_directory_exists.yaml | 2 +- .../test_directory_async.test_directory_exists.yaml | 4 ++-- .../tests/recordings/test_file.test_file_exists.yaml | 2 +- .../tests/recordings/test_file_async.test_file_exists.yaml | 4 ++-- .../recordings/test_file_system.test_file_system_exists.yaml | 2 +- .../test_file_system_async.test_file_system_exists.yaml | 4 ++-- .../azure-storage-file-datalake/tests/test_directory.py | 2 +- .../azure-storage-file-datalake/tests/test_directory_async.py | 2 +- sdk/storage/azure-storage-file-datalake/tests/test_file.py | 2 +- .../azure-storage-file-datalake/tests/test_file_async.py | 2 +- .../azure-storage-file-datalake/tests/test_file_system.py | 2 +- .../tests/test_file_system_async.py | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory.test_directory_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory.test_directory_exists.yaml index 59b7c23c1def..affe9cc1b5d7 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory.test_directory_exists.yaml +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory.test_directory_exists.yaml @@ -131,7 +131,7 @@ interactions: x-ms-version: - '2020-06-12' method: HEAD - uri: https://storagename.blob.core.windows.net/filesystem14f20f16/baddirectory + uri: https://storagename.blob.core.windows.net/filesystem14f20f16/nonexistentdir response: body: string: '' diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory_async.test_directory_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory_async.test_directory_exists.yaml index 1117759fed97..88894b51a0c0 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory_async.test_directory_exists.yaml +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_directory_async.test_directory_exists.yaml @@ -92,7 +92,7 @@ interactions: x-ms-version: - '2020-06-12' method: HEAD - uri: https://storagename.blob.core.windows.net/filesystem78031193/baddirectory + uri: https://storagename.blob.core.windows.net/filesystem78031193/nonexistentdir response: body: string: '' @@ -106,5 +106,5 @@ interactions: status: code: 404 message: The specified blob does not exist. - url: https://seanprodhierarchical.blob.core.windows.net/filesystem78031193/baddirectory + url: https://seanprodhierarchical.blob.core.windows.net/filesystem78031193/nonexistentdir version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file.test_file_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file.test_file_exists.yaml index c263a09eb3cb..eb536fc5d5bf 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file.test_file_exists.yaml +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file.test_file_exists.yaml @@ -173,7 +173,7 @@ interactions: x-ms-version: - '2020-06-12' method: HEAD - uri: https://storagename.blob.core.windows.net/filesystem8ebf0aac/directory8ebf0aac/badfilename + uri: https://storagename.blob.core.windows.net/filesystem8ebf0aac/directory8ebf0aac/nonexistentfile response: body: string: '' diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_async.test_file_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_async.test_file_exists.yaml index b05e918ee1e5..7c0c3e8a5c4c 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_async.test_file_exists.yaml +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_async.test_file_exists.yaml @@ -123,7 +123,7 @@ interactions: x-ms-version: - '2020-06-12' method: HEAD - uri: https://storagename.blob.core.windows.net/filesystemd8210d29/directoryd8210d29/badfilename + uri: https://storagename.blob.core.windows.net/filesystemd8210d29/directoryd8210d29/nonexistentfile response: body: string: '' @@ -137,5 +137,5 @@ interactions: status: code: 404 message: The specified blob does not exist. - url: https://seanprodhierarchical.blob.core.windows.net/filesystemd8210d29/directoryd8210d29/badfilename + url: https://seanprodhierarchical.blob.core.windows.net/filesystemd8210d29/directoryd8210d29/nonexistentfile version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_file_system_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_file_system_exists.yaml index d2691e18375e..d8f54ac30f05 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_file_system_exists.yaml +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_file_system_exists.yaml @@ -111,7 +111,7 @@ interactions: x-ms-version: - '2020-06-12' method: GET - uri: https://storagename.blob.core.windows.net/badfilesystem?restype=container + uri: https://storagename.blob.core.windows.net/nonexistentfs?restype=container response: body: string: "\uFEFFContainerNotFoundThe diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_file_system_exists.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_file_system_exists.yaml index b969818d3a79..e143018691cf 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_file_system_exists.yaml +++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_file_system_exists.yaml @@ -79,7 +79,7 @@ interactions: x-ms-version: - '2020-06-12' method: GET - uri: https://storagename.blob.core.windows.net/badfilesystem?restype=container + uri: https://storagename.blob.core.windows.net/nonexistentfs?restype=container response: body: string: "\uFEFFContainerNotFoundThe @@ -95,5 +95,5 @@ interactions: status: code: 404 message: The specified container does not exist. - url: https://seanprodhierarchical.blob.core.windows.net/badfilesystem?restype=container + url: https://seanprodhierarchical.blob.core.windows.net/nonexistentfs?restype=container version: 1 diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_directory.py b/sdk/storage/azure-storage-file-datalake/tests/test_directory.py index 5bdb97ec4ec7..0c11ff283ae5 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_directory.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_directory.py @@ -103,7 +103,7 @@ def test_directory_exists(self): directory_name = self._get_directory_reference() directory_client1 = self.dsc.get_directory_client(self.file_system_name, directory_name) - directory_client2 = self.dsc.get_directory_client(self.file_system_name, "baddirectory") + directory_client2 = self.dsc.get_directory_client(self.file_system_name, "nonexistentdir") directory_client1.create_directory() self.assertTrue(directory_client1.exists()) diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_directory_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_directory_async.py index 8ea57e604efb..146025b3da37 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_directory_async.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_directory_async.py @@ -128,7 +128,7 @@ async def _test_directory_exists(self): directory_name = self._get_directory_reference() directory_client1 = self.dsc.get_directory_client(self.file_system_name, directory_name) - directory_client2 = self.dsc.get_directory_client(self.file_system_name, "baddirectory") + directory_client2 = self.dsc.get_directory_client(self.file_system_name, "nonexistentdir") await directory_client1.create_directory() self.assertTrue(await directory_client1.exists()) diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file.py b/sdk/storage/azure-storage-file-datalake/tests/test_file.py index ee7f0e635562..6b2d4932df5d 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file.py @@ -110,7 +110,7 @@ def test_file_exists(self): directory_client.create_directory() file_client1 = directory_client.get_file_client('filename') - file_client2 = directory_client.get_file_client('badfilename') + file_client2 = directory_client.get_file_client('nonexistentfile') file_client1.create_file() self.assertTrue(file_client1.exists()) diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py index 8f4af97d3e6a..3c7a9ee1383e 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py @@ -122,7 +122,7 @@ async def _test_file_exists(self): await directory_client.create_directory() file_client1 = directory_client.get_file_client('filename') - file_client2 = directory_client.get_file_client('badfilename') + file_client2 = directory_client.get_file_client('nonexistentfile') await file_client1.create_file() self.assertTrue(await file_client1.exists()) diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py index f4685d617df0..93e79c1c9e97 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py @@ -77,7 +77,7 @@ def test_file_system_exists(self): # Act file_system_client1 = self.dsc.get_file_system_client(file_system_name) - file_system_client2 = self.dsc.get_file_system_client("badfilesystem") + file_system_client2 = self.dsc.get_file_system_client("nonexistentfs") file_system_client1.create_file_system() self.assertTrue(file_system_client1.exists()) diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py index 02edca6c6a36..42520ffd64a5 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py @@ -102,7 +102,7 @@ async def _test_file_system_exists(self): # Act file_system_client1 = self.dsc.get_file_system_client(file_system_name) - file_system_client2 = self.dsc.get_file_system_client("badfilesystem") + file_system_client2 = self.dsc.get_file_system_client("nonexistentfs") await file_system_client1.create_file_system() self.assertTrue(await file_system_client1.exists())