-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add missing await on delete_blob call per issue 459 #460
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
import tempfile | ||
from unittest import mock | ||
|
||
import azure.storage.blob | ||
import azure.storage.blob.aio | ||
import dask.dataframe as dd | ||
import numpy as np | ||
|
@@ -754,14 +753,8 @@ def test_rm_recursive(mock_delete_blob, storage): | |
mock.ANY, "root/c" | ||
), "The directory deletion should be the last call" | ||
|
||
|
||
@mock.patch.object( | ||
azure.storage.blob.aio.ContainerClient, | ||
"delete_blob", | ||
side_effect=azure.storage.blob.aio.ContainerClient.delete_blob, | ||
autospec=True, | ||
) | ||
def test_rm_recursive2(mock_delete_blob, storage): | ||
@pytest.mark.filterwarnings("error") | ||
def test_rm_recursive2(storage): | ||
fs = AzureBlobFileSystem( | ||
account_name=storage.account_name, connection_string=CONN_STR | ||
) | ||
|
@@ -774,7 +767,36 @@ def test_rm_recursive2(mock_delete_blob, storage): | |
with pytest.raises(FileNotFoundError): | ||
fs.ls("data/root") | ||
|
||
last_deleted_paths = [call.args[1] for call in mock_delete_blob.mock_calls[-7:]] | ||
|
||
async def test_rm_recursive_call_order(storage, mocker): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
from azure.storage.blob.aio import ContainerClient | ||
|
||
delete_blob_mock = mocker.patch.object(ContainerClient, "delete_blob", return_value=None) | ||
fs = AzureBlobFileSystem( | ||
account_name=storage.account_name, connection_string=CONN_STR | ||
) | ||
|
||
container_name = "data" | ||
file_paths = [ | ||
"root/a", | ||
"root/a/file.txt", | ||
"root/a1", | ||
"root/a1/file1.txt", | ||
"root/b", | ||
"root/b/file.txt", | ||
"root", | ||
"root/c", | ||
"root/c/file1.txt", | ||
"root/c/file2.txt", | ||
"root/d", | ||
"root/d/file_with_metadata.txt", | ||
"root/e+f", | ||
"root/e+f/file1.txt", | ||
"root/e+f/file2.txt", | ||
"root/rfile.txt" | ||
] | ||
await fs._rm_files(container_name=container_name, file_paths=file_paths) | ||
last_deleted_paths = [call.args[0] for call in delete_blob_mock.call_args_list[-7:]] | ||
assert last_deleted_paths == [ | ||
"root/e+f", | ||
"root/d", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified this test to remove the mocking so the delete_blob calls are executed asynchronously. This test ensures that the files in
data/root
are in fact removed. Also, the decorator will raise the RuntimeWarning emitted from the missingawait
(regression).