1313# limitations under the License.
1414
1515from unittest import mock
16+ import pytest
1617from google .auth import credentials as auth_credentials
1718from google .auth .credentials import AnonymousCredentials
1819from google .api_core import client_info as client_info_lib
@@ -185,6 +186,7 @@ def test_grpc_client_with_anon_creds(self, mock_grpc_gapic_client):
185186 credentials = anonymous_creds ,
186187 options = expected_options ,
187188 )
189+ mock_transport_cls .assert_called_once_with (channel = channel_sentinel )
188190
189191 @mock .patch ("google.cloud._storage_v2.StorageAsyncClient" )
190192 def test_user_agent_with_custom_client_info (self , mock_async_storage_client ):
@@ -209,3 +211,46 @@ def test_user_agent_with_custom_client_info(self, mock_async_storage_client):
209211 agent_version = f"gcloud-python/{ __version__ } "
210212 expected_user_agent = f"custom-app/1.0 { agent_version } "
211213 assert client_info .user_agent == expected_user_agent
214+
215+ @mock .patch ("google.cloud._storage_v2.StorageAsyncClient" )
216+ @pytest .mark .asyncio
217+ async def test_delete_object (self , mock_async_storage_client ):
218+ # Arrange
219+ mock_transport_cls = mock .MagicMock ()
220+ mock_async_storage_client .get_transport_class .return_value = mock_transport_cls
221+ mock_gapic_client = mock .AsyncMock ()
222+ mock_async_storage_client .return_value = mock_gapic_client
223+
224+ client = async_grpc_client .AsyncGrpcClient (
225+ credentials = _make_credentials (spec = AnonymousCredentials )
226+ )
227+
228+ bucket_name = "bucket"
229+ object_name = "object"
230+ generation = 123
231+ if_generation_match = 456
232+ if_generation_not_match = 789
233+ if_metageneration_match = 111
234+ if_metageneration_not_match = 222
235+
236+ # Act
237+ await client .delete_object (
238+ bucket_name ,
239+ object_name ,
240+ generation = generation ,
241+ if_generation_match = if_generation_match ,
242+ if_generation_not_match = if_generation_not_match ,
243+ if_metageneration_match = if_metageneration_match ,
244+ if_metageneration_not_match = if_metageneration_not_match ,
245+ )
246+
247+ # Assert
248+ call_args , call_kwargs = mock_gapic_client .delete_object .call_args
249+ request = call_kwargs ["request" ]
250+ assert request .bucket == "projects/_/buckets/bucket"
251+ assert request .object == "object"
252+ assert request .generation == generation
253+ assert request .if_generation_match == if_generation_match
254+ assert request .if_generation_not_match == if_generation_not_match
255+ assert request .if_metageneration_match == if_metageneration_match
256+ assert request .if_metageneration_not_match == if_metageneration_not_match
0 commit comments