@@ -224,6 +224,38 @@ async def test_flush_without_open_raises_value_error(mock_client):
224224await writer .flush ()
225225
226226
227+ @pytest .mark .asyncio
228+ @mock .patch (
229+ "google.cloud.storage._experimental.asyncio.async_appendable_object_writer._AsyncWriteObjectStream"
230+ )
231+ async def test_simple_flush (mock_write_object_stream ,mock_client ):
232+ """Test that flush sends the correct request and updates state."""
233+ # Arrange
234+ writer = AsyncAppendableObjectWriter (mock_client ,BUCKET ,OBJECT )
235+ writer ._is_stream_open = True
236+ mock_stream = mock_write_object_stream .return_value
237+ mock_stream .send = mock .AsyncMock ()
238+
239+ # Act
240+ await writer .simple_flush ()
241+
242+ # Assert
243+ mock_stream .send .assert_awaited_once_with (
244+ _storage_v2 .BidiWriteObjectRequest (flush = True )
245+ )
246+
247+
248+ @pytest .mark .asyncio
249+ async def test_simple_flush_without_open_raises_value_error (mock_client ):
250+ """Test that flush raises an error if the stream is not open."""
251+ writer = AsyncAppendableObjectWriter (mock_client ,BUCKET ,OBJECT )
252+ with pytest .raises (
253+ ValueError ,
254+ match = "Stream is not open. Call open\\ (\\ ) before simple_flush\\ (\\ )." ,
255+ ):
256+ await writer .simple_flush ()
257+
258+
227259@pytest .mark .asyncio
228260@mock .patch (
229261"google.cloud.storage._experimental.asyncio.async_appendable_object_writer._AsyncWriteObjectStream"
@@ -369,7 +401,7 @@ async def test_append_sends_data_in_chunks(mock_write_object_stream, mock_client
369401writer .persisted_size = 100
370402mock_stream = mock_write_object_stream .return_value
371403mock_stream .send = mock .AsyncMock ()
372- writer .flush = mock .AsyncMock ()
404+ writer .simple_flush = mock .AsyncMock ()
373405
374406data = b"a" * (_MAX_CHUNK_SIZE_BYTES + 1 )
375407await writer .append (data )
@@ -387,7 +419,7 @@ async def test_append_sends_data_in_chunks(mock_write_object_stream, mock_client
387419assert len (second_call [0 ][0 ].checksummed_data .content )== 1
388420
389421assert writer .offset == 100 + len (data )
390- writer .flush .assert_not_awaited ()
422+ writer .simple_flush .assert_not_awaited ()
391423
392424
393425@pytest .mark .asyncio
@@ -407,12 +439,12 @@ async def test_append_flushes_when_buffer_is_full(
407439writer .persisted_size = 0
408440mock_stream = mock_write_object_stream .return_value
409441mock_stream .send = mock .AsyncMock ()
410- writer .flush = mock .AsyncMock ()
442+ writer .simple_flush = mock .AsyncMock ()
411443
412444data = b"a" * _MAX_BUFFER_SIZE_BYTES
413445await writer .append (data )
414446
415- writer .flush .assert_awaited_once ()
447+ writer .simple_flush .assert_awaited_once ()
416448
417449
418450@pytest .mark .asyncio
@@ -430,12 +462,12 @@ async def test_append_handles_large_data(mock_write_object_stream, mock_client):
430462writer .persisted_size = 0
431463mock_stream = mock_write_object_stream .return_value
432464mock_stream .send = mock .AsyncMock ()
433- writer .flush = mock .AsyncMock ()
465+ writer .simple_flush = mock .AsyncMock ()
434466
435467data = b"a" * (_MAX_BUFFER_SIZE_BYTES * 2 + 1 )
436468await writer .append (data )
437469
438- assert writer .flush .await_count == 2
470+ assert writer .simple_flush .await_count == 2
439471
440472
441473@pytest .mark .asyncio
@@ -453,7 +485,7 @@ async def test_append_data_two_times(mock_write_object_stream, mock_client):
453485writer .persisted_size = 0
454486mock_stream = mock_write_object_stream .return_value
455487mock_stream .send = mock .AsyncMock ()
456- writer .flush = mock .AsyncMock ()
488+ writer .simple_flush = mock .AsyncMock ()
457489
458490data1 = b"a" * (_MAX_CHUNK_SIZE_BYTES + 10 )
459491await writer .append (data1 )
@@ -463,4 +495,4 @@ async def test_append_data_two_times(mock_write_object_stream, mock_client):
463495
464496total_data_length = len (data1 )+ len (data2 )
465497assert writer .offset == total_data_length
466- assert writer .flush .await_count == 0
498+ assert writer .simple_flush .await_count == 0