def test_push_payload(self):
     with mock.patch("push_notifications.gcm._gcm_send",
                     return_value=GCM_PLAIN_RESPONSE) as p:
         send_message("abc", {"message": "Hello world"}, "GCM")
         p.assert_called_once_with(
             b"data.message=Hello+world&registration_id=abc",
             "application/x-www-form-urlencoded;charset=UTF-8")
Esempio n. 2
0
 def test_fcm_push_payload(self):
     with mock.patch("push_notifications.gcm._fcm_send",
                     return_value=GCM_JSON) as p:
         send_message("abc", {"message": "Hello world"}, "FCM")
         p.assert_called_once_with(
             b'{"notification":{"body":"Hello world"},"registration_ids":["abc"]}',
             "application/json")
	def test_push_payload_params(self):
		with mock.patch("push_notifications.gcm._gcm_send", return_value=GCM_PLAIN_RESPONSE) as p:
			send_message(
				"abc", {"message": "Hello world"}, "GCM", delay_while_idle=True, time_to_live=3600
			)
			p.assert_called_once_with(
				b"data.message=Hello+world&delay_while_idle=1&registration_id=abc&time_to_live=3600",
				"application/x-www-form-urlencoded;charset=UTF-8")
	def test_gcm_push_payload_params(self):
		with mock.patch("push_notifications.gcm._gcm_send", return_value=GCM_JSON_RESPONSE) as p:
			send_message(
				"abc", {"message": "Hello world"}, "GCM", delay_while_idle=True, time_to_live=3600, foo='bar',
			)
			p.assert_called_once_with(
				b'{"data":{"message":"Hello world"},"delay_while_idle":true,'
				b'"registration_ids":["abc"],"time_to_live":3600}',
				"application/json")
Esempio n. 5
0
def send_notif(sender, instance, created, **kwargs):
    msg = instance.message
    if created:
        send_message(None, {
            "title": "Pembaharuan Data",
            "body": msg
        },
                     to=instance.topic_fcm,
                     cloud_type='FCM')
	def test_gcm_push_payload_params(self):
		with mock.patch("push_notifications.gcm._gcm_send", return_value=GCM_JSON) as p:
			send_message(
				"abc", {"message": "Hello world"}, "GCM",
				delay_while_idle=True, time_to_live=3600, foo="bar",
			)
			p.assert_called_once_with(
				b'{"data":{"message":"Hello world"},"delay_while_idle":true,'
				b'"registration_ids":["abc"],"time_to_live":3600}',
				"application/json", application_id=None)
 def test_push_payload_params(self):
     with mock.patch("push_notifications.gcm._gcm_send",
                     return_value=GCM_PLAIN_RESPONSE) as p:
         send_message("abc", {"message": "Hello world"},
                      "GCM",
                      delay_while_idle=True,
                      time_to_live=3600)
         p.assert_called_once_with(
             b"data.message=Hello+world&delay_while_idle=1&registration_id=abc&time_to_live=3600",
             "application/x-www-form-urlencoded;charset=UTF-8")
	def test_push_payload_with_app_id(self):
		with mock.patch("push_notifications.gcm._gcm_send", return_value=GCM_JSON) as p:
			send_message("abc", {"message": "Hello world"}, "GCM")
			p.assert_called_once_with(
				b'{"data":{"message":"Hello world"},"registration_ids":["abc"]}',
				"application/json", application_id=None)
		with mock.patch("push_notifications.gcm._gcm_send", return_value=GCM_JSON) as p:
			send_message("abc", {"message": "Hello world"}, "GCM")
			p.assert_called_once_with(
				b'{"data":{"message":"Hello world"},"registration_ids":["abc"]}',
				"application/json", application_id=None)
Esempio n. 9
0
 def test_fcm_push_payload_params(self):
     with mock.patch("push_notifications.gcm._fcm_send",
                     return_value=GCM_JSON) as p:
         send_message(
             "abc",
             {
                 "message": "Hello world",
                 "title": "Push notification",
                 "other": "misc"
             },
             "FCM",
             delay_while_idle=True,
             time_to_live=3600,
             foo="bar",
         )
         p.assert_called_once_with(
             b'{"data":{"other":"misc"},"delay_while_idle":true,'
             b'"notification":{"body":"Hello world","title":"Push notification"},'
             b'"registration_ids":["abc"],"time_to_live":3600}',
             "application/json")
	def test_push_payload(self):
		with mock.patch("push_notifications.gcm._gcm_send", return_value=GCM_PLAIN_RESPONSE) as p:
			send_message("abc", {"message": "Hello world"}, "GCM")
			p.assert_called_once_with(
				b"data.message=Hello+world&registration_id=abc",
				"application/x-www-form-urlencoded;charset=UTF-8")