def test_parse_exception(self): """ Make sure we can handle a simualted exception from Parse """ with self.assertRaises(ChannelError): ParsePushNotificationChannelProvider.publish_notification( 'test-runner', 'test-type', { 'foo': 'bar', 'one': 'two' }, ['test_channel_id'])
def test_publish_notification(self, mock_parse_push): """ Happy path testing of a push notification """ ParsePushNotificationChannelProvider.publish_notification( 'test-runner', 'test-type', { 'foo': 'bar', 'one': 'two' }, ['test_channel_id']) self.assertTrue(mock_parse_push.alert.called) mock_parse_push.alert.assert_called_with(data=self.msg.payload, channels=['test_channel_id'])
def test_parse_exception(self): """ Make sure we can handle a simualted exception from Parse """ with self.assertRaises(ChannelError): ParsePushNotificationChannelProvider.publish_notification( 'test-runner', 'test-type', { 'foo': 'bar', 'one': 'two' }, ['test_channel_id'] )
def test_publish_notification(self, mock_parse_push): """ Happy path testing of a push notification """ ParsePushNotificationChannelProvider.publish_notification( 'test-runner', 'test-type', { 'foo': 'bar', 'one': 'two' }, ['test_channel_id'] ) self.assertTrue(mock_parse_push.alert.called) mock_parse_push.alert.assert_called_with(data=self.msg.payload, channels=['test_channel_id'])
def test_publish_timed_notification(self, mock_parse_push): """ Happy path testing of a push notification that is put on a timer """ send_at = datetime.now(pytz.UTC) - timedelta(days=1) ParsePushNotificationChannelProvider.publish_notification( 'test-runner', 'test-type', { 'foo': 'bar', 'one': 'two' }, ['test_channel_id'], send_at=send_at) # force the timer to execute poll_and_execute_timers() # Parse should have been called self.assertTrue(mock_parse_push.alert.called) mock_parse_push.alert.assert_called_with(data=self.msg.payload, channels=['test_channel_id'])
def test_publish_timed_notification(self, mock_parse_push): """ Happy path testing of a push notification that is put on a timer """ send_at = datetime.now(pytz.UTC) - timedelta(days=1) ParsePushNotificationChannelProvider.publish_notification( 'test-runner', 'test-type', { 'foo': 'bar', 'one': 'two' }, ['test_channel_id'], send_at=send_at ) # force the timer to execute poll_and_execute_timers() # Parse should have been called self.assertTrue(mock_parse_push.alert.called) mock_parse_push.alert.assert_called_with(data=self.msg.payload, channels=['test_channel_id'])