@@ -38,7 +38,7 @@ def test_can_create_save_device(self):
38
38
def test_fcm_send_message (self ):
39
39
device = GCMDevice .objects .create (registration_id = "abc" , cloud_message_type = "FCM" )
40
40
with mock .patch (
41
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS
41
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS
42
42
) as p :
43
43
device .send_message ("Hello world" )
44
44
@@ -65,7 +65,7 @@ def test_fcm_send_message(self):
65
65
def test_fcm_send_message_with_fcm_message (self ):
66
66
device = GCMDevice .objects .create (registration_id = "abc" , cloud_message_type = "FCM" )
67
67
with mock .patch (
68
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS
68
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS
69
69
) as p :
70
70
message_to_send = messaging .Message (
71
71
notification = messaging .Notification (
@@ -99,7 +99,7 @@ def test_fcm_send_message_with_fcm_message(self):
99
99
def test_fcm_send_message_extra_data (self ):
100
100
device = GCMDevice .objects .create (registration_id = "abc" , cloud_message_type = "FCM" )
101
101
with mock .patch (
102
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS
102
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS
103
103
) as p :
104
104
device .send_message ("Hello world" , extra = {"foo" : "bar" })
105
105
@@ -125,7 +125,7 @@ def test_fcm_send_message_extra_data(self):
125
125
def test_fcm_send_message_extra_options (self ):
126
126
device = GCMDevice .objects .create (registration_id = "abc" , cloud_message_type = "FCM" )
127
127
with mock .patch (
128
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS
128
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS
129
129
) as p :
130
130
device .send_message ("Hello world" , collapse_key = "test_key" , foo = "bar" )
131
131
@@ -152,7 +152,7 @@ def test_fcm_send_message_extra_options(self):
152
152
def test_fcm_send_message_extra_notification (self ):
153
153
device = GCMDevice .objects .create (registration_id = "abc" , cloud_message_type = "FCM" )
154
154
with mock .patch (
155
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS
155
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS
156
156
) as p :
157
157
device .send_message ("Hello world" , extra = {"icon" : "test_icon" }, title = "test" )
158
158
@@ -180,7 +180,7 @@ def test_fcm_send_message_extra_notification(self):
180
180
def test_fcm_send_message_extra_options_and_notification_and_data (self ):
181
181
device = GCMDevice .objects .create (registration_id = "abc" , cloud_message_type = "FCM" )
182
182
with mock .patch (
183
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS
183
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS
184
184
) as p :
185
185
device .send_message (
186
186
"Hello world" ,
@@ -215,7 +215,7 @@ def test_fcm_send_message_to_multiple_devices(self):
215
215
self ._create_fcm_devices (["abc" , "abc1" ])
216
216
217
217
with mock .patch (
218
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS_MULTIPLE
218
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS_MULTIPLE
219
219
) as p :
220
220
GCMDevice .objects .all ().send_message ("Hello world" )
221
221
@@ -245,7 +245,7 @@ def test_fcm_send_message_to_multiple_devices_fcm_message(self):
245
245
self ._create_fcm_devices (["abc" , "abc1" ])
246
246
247
247
with mock .patch (
248
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS_MULTIPLE
248
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS_MULTIPLE
249
249
) as p :
250
250
message_to_send = messaging .Message (
251
251
notification = messaging .Notification (
@@ -283,7 +283,7 @@ def test_gcm_send_message_does_not_send(self):
283
283
device = GCMDevice .objects .create (registration_id = "abc" , cloud_message_type = "GCM" )
284
284
285
285
with mock .patch (
286
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS_MULTIPLE
286
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS_MULTIPLE
287
287
) as p :
288
288
message_to_send = messaging .Message (
289
289
notification = messaging .Notification (
@@ -299,7 +299,7 @@ def test_gcm_send_multiple_message_does_not_send(self):
299
299
self ._create_devices (["abc" , "abc1" ])
300
300
301
301
with mock .patch (
302
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS_MULTIPLE
302
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS_MULTIPLE
303
303
) as p :
304
304
message_to_send = messaging .Message (
305
305
notification = messaging .Notification (
@@ -318,7 +318,7 @@ def test_fcm_send_message_active_devices(self):
318
318
GCMDevice .objects .create (registration_id = "xyz" , active = False , cloud_message_type = "FCM" )
319
319
320
320
with mock .patch (
321
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS_MULTIPLE
321
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS_MULTIPLE
322
322
) as p :
323
323
GCMDevice .objects .all ().send_message ("Hello world" )
324
324
@@ -344,7 +344,7 @@ def test_fcm_send_message_collapse_to_multiple_devices(self):
344
344
self ._create_fcm_devices (["abc" , "abc1" ])
345
345
346
346
with mock .patch (
347
- "firebase_admin.messaging.send_all " , return_value = responses .FCM_SUCCESS_MULTIPLE
347
+ "firebase_admin.messaging.send_each " , return_value = responses .FCM_SUCCESS_MULTIPLE
348
348
) as p :
349
349
GCMDevice .objects .all ().send_message ("Hello world" , collapse_key = "test_key" )
350
350
@@ -386,7 +386,7 @@ def test_fcm_send_message_to_single_device_with_error(self):
386
386
[SendResponse (resp = {"name" : "..." }, exception = error )]
387
387
)
388
388
with mock .patch (
389
- "firebase_admin.messaging.send_all " , return_value = return_value
389
+ "firebase_admin.messaging.send_each " , return_value = return_value
390
390
):
391
391
device = GCMDevice .objects .get (registration_id = devices [index ])
392
392
device .send_message ("Hello World!" )
@@ -399,7 +399,7 @@ def test_fcm_send_message_to_single_device_with_error_mismatch(self):
399
399
[SendResponse (resp = {"name" : "..." }, exception = OSError ())]
400
400
)
401
401
with mock .patch (
402
- "firebase_admin.messaging.send_all " ,
402
+ "firebase_admin.messaging.send_each " ,
403
403
return_value = return_value
404
404
):
405
405
# these errors are not device specific, device is not deactivated
@@ -417,7 +417,7 @@ def test_fcm_send_message_to_multiple_devices_with_error(self):
417
417
SendResponse (resp = {"name" : "..." }, exception = InvalidArgumentError ("Invalid registration" )),
418
418
])
419
419
with mock .patch (
420
- "firebase_admin.messaging.send_all " , return_value = return_value
420
+ "firebase_admin.messaging.send_each " , return_value = return_value
421
421
):
422
422
GCMDevice .objects .all ().send_message ("Hello World" )
423
423
self .assertFalse (GCMDevice .objects .get (registration_id = "abc" ).active )
@@ -436,7 +436,7 @@ def test_fcm_send_message_to_multiple_devices_with_error_b(self):
436
436
])
437
437
438
438
with mock .patch (
439
- "firebase_admin.messaging.send_all " , return_value = return_value
439
+ "firebase_admin.messaging.send_each " , return_value = return_value
440
440
):
441
441
GCMDevice .objects .all ().send_message ("Hello World" )
442
442
self .assertTrue (GCMDevice .objects .get (registration_id = "abc" ).active )
@@ -448,14 +448,14 @@ def test_fcm_send_message_with_no_reg_ids(self):
448
448
self ._create_fcm_devices (["abc" , "abc1" ])
449
449
450
450
with mock .patch (
451
- "firebase_admin.messaging.send_all " ,
451
+ "firebase_admin.messaging.send_each " ,
452
452
return_value = responses .FCM_SUCCESS_MULTIPLE
453
453
) as p :
454
454
GCMDevice .objects .filter (registration_id = "xyz" ).send_message ("Hello World" )
455
455
p .assert_not_called ()
456
456
457
457
with mock .patch (
458
- "firebase_admin.messaging.send_all " ,
458
+ "firebase_admin.messaging.send_each " ,
459
459
return_value = responses .FCM_SUCCESS_MULTIPLE
460
460
) as p :
461
461
reg_ids = [obj .registration_id for obj in GCMDevice .objects .all ()]
0 commit comments