@@ -157,11 +157,13 @@ def test_fids_type(self):
157157 assert len (message .fids ) == 500
158158
159159 def test_tokens_deprecation_warning (self ):
160- with pytest .deprecated_call ():
160+ msg = 'MulticastMessage.tokens is deprecated. Use fids instead.'
161+ with pytest .warns (DeprecationWarning , match = msg ):
161162 messaging .MulticastMessage (tokens = ['token' ])
162163
163164 def test_tokens_deprecation_warning_positional (self ):
164- with pytest .deprecated_call ():
165+ msg = 'MulticastMessage.tokens is deprecated. Use fids instead.'
166+ with pytest .warns (DeprecationWarning , match = msg ):
165167 messaging .MulticastMessage (['token' ])
166168
167169
@@ -220,7 +222,8 @@ def test_empty_message(self):
220222 check_encoding (messaging .Message (condition = 'value' ), {'condition' : 'value' })
221223
222224 def test_token_deprecation_warning (self ):
223- with pytest .deprecated_call ():
225+ msg = 'Message.token is deprecated. Use fid instead.'
226+ with pytest .warns (DeprecationWarning , match = msg ):
224227 messaging .Message (token = 'value' )
225228
226229 @pytest .mark .parametrize ('data' , NON_DICT_ARGS )
@@ -2287,6 +2290,48 @@ def test_send_each_for_multicast_fids(self):
22872290 assert all (r .success for r in batch_response .responses )
22882291 assert not any (r .exception for r in batch_response .responses )
22892292
2293+ @respx .mock
2294+ @pytest .mark .asyncio
2295+ async def test_send_each_for_multicast_async (self ):
2296+ responses = [
2297+ respx .MockResponse (200 , http_version = 'HTTP/2' , json = {'name' : 'message-id1' }),
2298+ respx .MockResponse (200 , http_version = 'HTTP/2' , json = {'name' : 'message-id2' }),
2299+ ]
2300+ msg = messaging .MulticastMessage (tokens = ['foo1' , 'foo2' ])
2301+ route = respx .request (
2302+ method = 'POST' ,
2303+ url = 'https://fcm.googleapis.com/v1/projects/explicit-project-id/messages:send'
2304+ )
2305+ route .side_effect = responses
2306+ batch_response = await messaging .send_each_for_multicast_async (msg , dry_run = True )
2307+ assert batch_response .success_count == 2
2308+ assert batch_response .failure_count == 0
2309+ assert len (batch_response .responses ) == 2
2310+ assert [r .message_id for r in batch_response .responses ] == ['message-id1' , 'message-id2' ]
2311+ assert all (r .success for r in batch_response .responses )
2312+ assert not any (r .exception for r in batch_response .responses )
2313+
2314+ @respx .mock
2315+ @pytest .mark .asyncio
2316+ async def test_send_each_for_multicast_async_fids (self ):
2317+ responses = [
2318+ respx .MockResponse (200 , http_version = 'HTTP/2' , json = {'name' : 'message-id1' }),
2319+ respx .MockResponse (200 , http_version = 'HTTP/2' , json = {'name' : 'message-id2' }),
2320+ ]
2321+ msg = messaging .MulticastMessage (fids = ['foo1' , 'foo2' ])
2322+ route = respx .request (
2323+ method = 'POST' ,
2324+ url = 'https://fcm.googleapis.com/v1/projects/explicit-project-id/messages:send'
2325+ )
2326+ route .side_effect = responses
2327+ batch_response = await messaging .send_each_for_multicast_async (msg , dry_run = True )
2328+ assert batch_response .success_count == 2
2329+ assert batch_response .failure_count == 0
2330+ assert len (batch_response .responses ) == 2
2331+ assert [r .message_id for r in batch_response .responses ] == ['message-id1' , 'message-id2' ]
2332+ assert all (r .success for r in batch_response .responses )
2333+ assert not any (r .exception for r in batch_response .responses )
2334+
22902335 @pytest .mark .parametrize ('status' , HTTP_ERROR_CODES )
22912336 def test_send_each_for_multicast_detailed_error (self , status ):
22922337 success_payload = json .dumps ({'name' : 'message-id' })
0 commit comments