|
2 | 2 | import os |
3 | 3 | import tempfile |
4 | 4 | from unittest import mock |
| 5 | +from unittest.mock import patch |
5 | 6 |
|
6 | 7 | import azure.storage.blob.aio |
7 | 8 | import dask.dataframe as dd |
@@ -2112,19 +2113,20 @@ def test_user_agent_blob_file_initializer( |
2112 | 2113 | assert mock_client.call_args.kwargs["user_agent"] == f"adlfs/{__version__}" |
2113 | 2114 |
|
2114 | 2115 |
|
| 2116 | +@patch("adlfs.spec.AIOBlobServiceClient") |
2115 | 2117 | def test_user_agent_connection_str( |
2116 | 2118 | storage: azure.storage.blob.BlobServiceClient, mocker |
2117 | 2119 | ): |
2118 | 2120 | from adlfs import __version__ |
2119 | 2121 |
|
2120 | | - fs = AzureBlobFileSystem( |
2121 | | - account_name=storage.account_name, connection_string=CONN_STR |
2122 | | - ) |
2123 | | - mock_client = mocker.patch.object( |
2124 | | - AIOBlobServiceClient, "from_connection_string", return_value=mocker.AsyncMock() |
| 2122 | + mock_client_instance = mocker.MagicMock() |
| 2123 | + mock_client_instance.close = mocker.AsyncMock() |
| 2124 | + mock_client = mocker.patch( |
| 2125 | + "adlfs.spec.AIOBlobServiceClient.from_connection_string", |
| 2126 | + return_value=mock_client_instance, |
2125 | 2127 | ) |
2126 | 2128 |
|
2127 | | - fs.do_connect() |
| 2129 | + AzureBlobFileSystem(account_name=storage.account_name, connection_string=CONN_STR) |
2128 | 2130 | mock_client.assert_called_once() |
2129 | 2131 | assert "user_agent" in mock_client.call_args.kwargs |
2130 | 2132 | assert mock_client.call_args.kwargs["user_agent"] == f"adlfs/{__version__}" |
|
0 commit comments