예제 #1
0
 def test_fcm_message_platform_config_override(self):
     platform_config = PlatformConfig(priority=PlatformPriority.HIGH,
                                      collapse_key='collapse_key')
     apns_config = messaging.APNSConfig(
         headers={'apns-collapse-id': 'ios_collapse_key'})
     request = FCMRequest(self._app,
                          notification=MockNotification(
                              platform_config=platform_config,
                              apns_config=apns_config),
                          topic='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertIsNotNone(message.data)
     self.assertIsNone(message.notification)
     self.assertTrue(isinstance(message.android, messaging.AndroidConfig))
     self.assertTrue(isinstance(message.apns, messaging.APNSConfig))
     self.assertEqual(message.apns.headers,
                      {'apns-collapse-id': 'ios_collapse_key'})
     self.assertTrue(isinstance(message.webpush, messaging.WebpushConfig))
     self.assertEqual(message.webpush.headers, {
         'Topic': 'collapse_key',
         'Urgency': 'high'
     })
     self.assertIsNone(message.token)
     self.assertEqual(message.topic, 'abc')
     self.assertIsNone(message.condition)
예제 #2
0
 def test_fcm_message_empty(self):
     request = FCMRequest(self._app, notification=MockNotification(), token='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertIsNotNone(message.data)
     self.assertIsNone(message.notification)
     self.assertIsNone(message.android)
     self.assertIsNone(message.apns)
     self.assertIsNone(message.webpush)
     self.assertEqual(message.token, 'abc')
     self.assertIsNone(message.topic)
     self.assertIsNone(message.condition)
예제 #3
0
 def test_fcm_message_platform_config(self):
     platform_config = PlatformConfig(priority=PlatformPriority.HIGH, collapse_key='collapse_key')
     request = FCMRequest(self._app, notification=MockNotification(platform_config=platform_config), topic='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertIsNotNone(message.data)
     self.assertIsNone(message.notification)
     self.assertTrue(isinstance(message.android, messaging.AndroidConfig))
     self.assertTrue(isinstance(message.apns, messaging.APNSConfig))
     self.assertTrue(isinstance(message.webpush, messaging.WebpushConfig))
     self.assertIsNone(message.token)
     self.assertEqual(message.topic, 'abc')
     self.assertIsNone(message.condition)
예제 #4
0
 def test_fcm_message_notification(self):
     platform_config = PlatformConfig(priority=PlatformPriority.HIGH, collapse_key='collapse_key')
     request = FCMRequest(self._app, notification=MockNotification(fcm_notification=messaging.Notification(title='Title', body='Some body message')), condition='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertIsNotNone(message.data)
     self.assertTrue(isinstance(message.notification, messaging.Notification))
     self.assertIsNone(message.android)
     self.assertIsNone(message.apns)
     self.assertIsNone(message.webpush)
     self.assertIsNone(message.token)
     self.assertIsNone(message.topic)
     self.assertEqual(message.condition, 'abc')
예제 #5
0
 def test_fcm_message_data_payload(self):
     platform_config = PlatformConfig(priority=PlatformPriority.HIGH, collapse_key='collapse_key')
     request = FCMRequest(self._app, notification=MockNotification(data_payload={'some_data': 'some test data'}), condition='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertEqual(message.data, {'notification_type': 'verification', 'some_data': 'some test data'})
     self.assertIsNone(message.notification)
     self.assertIsNone(message.android)
     self.assertIsNone(message.apns)
     self.assertIsNone(message.webpush)
     self.assertIsNone(message.token)
     self.assertIsNone(message.topic)
     self.assertEqual(message.condition, 'abc')
예제 #6
0
 def test_fcm_message_empty(self):
     request = FCMRequest(self._app,
                          notification=MockNotification(),
                          token='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertIsNotNone(message.data)
     self.assertIsNone(message.notification)
     self.assertIsNone(message.android)
     self.assertIsNone(message.apns)
     self.assertIsNone(message.webpush)
     self.assertEqual(message.token, 'abc')
     self.assertIsNone(message.topic)
     self.assertIsNone(message.condition)
예제 #7
0
 def test_fcm_message_platform_config_override(self):
     platform_config = PlatformConfig(priority=PlatformPriority.HIGH, collapse_key='collapse_key')
     apns_config = messaging.APNSConfig(headers={'apns-collapse-id': 'ios_collapse_key'})
     request = FCMRequest(self._app, notification=MockNotification(platform_config=platform_config, apns_config=apns_config), topic='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertIsNotNone(message.data)
     self.assertIsNone(message.notification)
     self.assertTrue(isinstance(message.android, messaging.AndroidConfig))
     self.assertTrue(isinstance(message.apns, messaging.APNSConfig))
     self.assertEqual(message.apns.headers, {'apns-collapse-id': 'ios_collapse_key'})
     self.assertTrue(isinstance(message.webpush, messaging.WebpushConfig))
     self.assertEqual(message.webpush.headers, {'Topic': 'collapse_key', 'Urgency': 'high'})
     self.assertIsNone(message.token)
     self.assertEqual(message.topic, 'abc')
     self.assertIsNone(message.condition)
예제 #8
0
 def test_fcm_message_data_payload_default(self):
     platform_config = PlatformConfig(priority=PlatformPriority.HIGH,
                                      collapse_key='collapse_key')
     request = FCMRequest(self._app,
                          notification=MockNotification(),
                          condition='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertEqual(message.data, {'notification_type': 'verification'})
     self.assertIsNone(message.notification)
     self.assertIsNone(message.android)
     self.assertIsNone(message.apns)
     self.assertIsNone(message.webpush)
     self.assertIsNone(message.token)
     self.assertIsNone(message.topic)
     self.assertEqual(message.condition, 'abc')
예제 #9
0
 def test_fcm_message_platform_config(self):
     platform_config = PlatformConfig(priority=PlatformPriority.HIGH,
                                      collapse_key='collapse_key')
     request = FCMRequest(
         self._app,
         notification=MockNotification(platform_config=platform_config),
         topic='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertIsNotNone(message.data)
     self.assertIsNone(message.notification)
     self.assertTrue(isinstance(message.android, messaging.AndroidConfig))
     self.assertTrue(isinstance(message.apns, messaging.APNSConfig))
     self.assertTrue(isinstance(message.webpush, messaging.WebpushConfig))
     self.assertIsNone(message.token)
     self.assertEqual(message.topic, 'abc')
     self.assertIsNone(message.condition)
예제 #10
0
 def test_fcm_message_notification(self):
     platform_config = PlatformConfig(priority=PlatformPriority.HIGH,
                                      collapse_key='collapse_key')
     request = FCMRequest(self._app,
                          notification=MockNotification(
                              fcm_notification=messaging.Notification(
                                  title='Title', body='Some body message')),
                          condition='abc')
     message = request._fcm_message()
     self.assertIsNotNone(message)
     self.assertIsNotNone(message.data)
     self.assertTrue(
         isinstance(message.notification, messaging.Notification))
     self.assertIsNone(message.android)
     self.assertIsNone(message.apns)
     self.assertIsNone(message.webpush)
     self.assertIsNone(message.token)
     self.assertIsNone(message.topic)
     self.assertEqual(message.condition, 'abc')