Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit 60930ed

Browse files
committed
resolve comments
1 parent 8208d76 commit 60930ed

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

google/cloud/storage/asyncio/async_grpc_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ async def get_object(
215215
if_generation_not_match=if_generation_not_match,
216216
if_metageneration_match=if_metageneration_match,
217217
if_metageneration_not_match=if_metageneration_not_match,
218-
soft_deleted=soft_deleted if soft_deleted is not None else False,
218+
soft_deleted=soft_deleted or False,
219219
**kwargs,
220220
)
221221

tests/system/test_zonal.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,3 +601,56 @@ async def _run():
601601
gc.collect()
602602

603603
event_loop.run_until_complete(_run())
604+
605+
def test_get_object_after_appendable_write(
606+
grpc_clients,
607+
grpc_client_direct,
608+
event_loop,
609+
storage_client,
610+
blobs_to_delete,
611+
):
612+
"""Test getting object metadata after writing with AsyncAppendableObjectWriter.
613+
614+
This test:
615+
1. Creates a test object using AsyncAppendableObjectWriter
616+
2. Appends content to the object (without finalizing)
617+
3. Closes the write stream
618+
4. Fetches the object metadata using AsyncGrpcClient.get_object()
619+
5. Verifies the object size matches the written data
620+
"""
621+
622+
async def _run():
623+
grpc_client = grpc_client_direct
624+
object_name = f"test-get-object-{uuid.uuid4().hex}"
625+
test_data = b"Some test data bytes."
626+
expected_size = len(test_data)
627+
628+
writer = AsyncAppendableObjectWriter(
629+
grpc_client,
630+
_ZONAL_BUCKET,
631+
object_name,
632+
)
633+
634+
await writer.open()
635+
await writer.append(test_data)
636+
await writer.close(finalize_on_close=False)
637+
638+
obj = await grpc_client.get_object(
639+
bucket_name=_ZONAL_BUCKET,
640+
object_name=object_name,
641+
)
642+
643+
# Assert
644+
assert obj is not None
645+
assert obj.name == object_name
646+
assert obj.bucket == f"projects/_/buckets/{_ZONAL_BUCKET}"
647+
assert obj.size == expected_size, (
648+
f"Expected object size {expected_size}, got {obj.size}"
649+
)
650+
651+
# Cleanup
652+
blobs_to_delete.append(storage_client.bucket(_ZONAL_BUCKET).blob(object_name))
653+
del writer
654+
gc.collect()
655+
656+
event_loop.run_until_complete(_run())

tests/unit/asyncio/test_async_grpc_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ async def test_delete_object(self, mock_async_storage_client):
254254
assert request.if_generation_not_match == if_generation_not_match
255255
assert request.if_metageneration_match == if_metageneration_match
256256
assert request.if_metageneration_not_match == if_metageneration_not_match
257+
assert request.soft_deleted is False
257258

258259
@mock.patch("google.cloud._storage_v2.StorageAsyncClient")
259260
@pytest.mark.asyncio

0 commit comments

Comments
 (0)