def test_gcm_push_payload_many(self): with mock.patch("push_notifications.gcm._gcm_send", return_value=GCM_JSON_MULTIPLE) as p: send_bulk_message(["abc", "123"], {"message": "Hello world"}, "GCM") p.assert_called_once_with( b'{"data":{"message":"Hello world"},"registration_ids":["abc","123"]}', "application/json", application_id=None)
def test_bulk_push_payload(self): with mock.patch("push_notifications.gcm._gcm_send", return_value=GCM_JSON_RESPONSE) as p: send_bulk_message(["abc", "123"], {"message": "Hello world"}, "GCM") p.assert_called_once_with( b'{"data":{"message":"Hello world"},"registration_ids":["abc","123"]}', "application/json")
def test_fcm_push_payload_many(self): with mock.patch("push_notifications.gcm._fcm_send", return_value=GCM_JSON_MULTIPLE) as p: send_bulk_message(["abc", "123"], {"message": "Hello world"}, "FCM") p.assert_called_once_with( b'{"notification":{"body":"Hello world"},"registration_ids":["abc","123"]}', "application/json")
def test_fcm_send_message_with_no_reg_ids(self): self._create_fcm_devices(["abc", "abc1"]) with mock.patch("push_notifications.gcm._cm_send_plain", return_value="") as p: GCMDevice.objects.filter(registration_id="xyz").send_message("Hello World") p.assert_not_called() with mock.patch("push_notifications.gcm._cm_send_json", return_value="") as p: reg_ids = [obj.registration_id for obj in GCMDevice.objects.all()] send_bulk_message(reg_ids, {"message": "Hello World"}, "FCM") p.assert_called_once_with( [u"abc", u"abc1"], {"message": "Hello World"}, cloud_type="FCM" )