feat: expose `DELETE_OBJECT` in `AsyncGrpcClient` (#1718) · googleapis/python-storage@c8dd7a0 · GitHub
Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit c8dd7a0

Browse files
authored
feat: expose DELETE_OBJECT in AsyncGrpcClient (#1718)
Expose `DELETE_OBJECT` in `AsyncGrpcClient`
1 parent 08bc708 commit c8dd7a0

3 files changed

Lines changed: 129 additions & 1 deletion

File tree

google/cloud/storage/asyncio/async_grpc_client.py

Lines changed: 52 additions & 0 deletions

tests/system/test_zonal.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from google.cloud.storage.asyncio.async_multi_range_downloader import (
2020
AsyncMultiRangeDownloader,
2121
)
22-
from google.api_core.exceptions import FailedPrecondition
22+
from google.api_core.exceptions import FailedPrecondition, NotFound
2323

2424

2525
pytestmark = pytest.mark.skipif(
@@ -570,3 +570,34 @@ async def _run():
570570
blobs_to_delete.append(storage_client.bucket(_ZONAL_BUCKET).blob(object_name))
571571

572572
event_loop.run_until_complete(_run())
573+
574+
575+
def test_delete_object_using_grpc_client(event_loop, grpc_client_direct):
576+
"""
577+
Test that a new writer when specifies `None` overrides the existing object.
578+
"""
579+
object_name = f"test_append_with_generation-{uuid.uuid4()}"
580+
581+
async def _run():
582+
writer = AsyncAppendableObjectWriter(
583+
grpc_client_direct, _ZONAL_BUCKET, object_name, generation=0
584+
)
585+
586+
# Empty object is created.
587+
await writer.open()
588+
await writer.append(b"some_bytes")
589+
await writer.close()
590+
591+
await grpc_client_direct.delete_object(_ZONAL_BUCKET, object_name)
592+
593+
# trying to get raises raises 404.
594+
with pytest.raises(NotFound):
595+
# TODO: Remove this once GET_OBJECT is exposed in `AsyncGrpcClient`
596+
await grpc_client_direct._grpc_client.get_object(
597+
bucket=f"projects/_/buckets/{_ZONAL_BUCKET}", object_=object_name
598+
)
599+
# cleanup
600+
del writer
601+
gc.collect()
602+
603+
event_loop.run_until_complete(_run())

tests/unit/asyncio/test_async_grpc_client.py

Lines changed: 45 additions & 0 deletions

0 commit comments

Comments
 (0)