def test_notifications_error_from_parse(self, mock_parse_push, mock_log_exception): PushNotificationConfig(enabled=True).save() from parse_rest.core import ParseError mock_parse_push.alert.side_effect = ParseError self.post_course_update(send_push_notification=True) self.assertTrue(mock_log_exception.called)
def test_notifications_enabled(self): PushNotificationConfig(enabled=True).save() self.assertTrue(PushNotificationConfig.is_enabled())
def test_notifications_defaults(self): self.assertFalse(PushNotificationConfig.is_enabled())
def test_notifications_sent_to_parse(self, mock_parse_push): PushNotificationConfig(enabled=True).save() self.post_course_update(send_push_notification=True) self.assertEquals(mock_parse_push.alert.call_count, 2)
def test_notifications_enabled_and_sent(self, mock_push_update): PushNotificationConfig(enabled=True).save() self.post_course_update(send_push_notification=True) self.assertTrue(mock_push_update.called)
def test_notifications_enabled_but_not_requested(self, mock_push_update): PushNotificationConfig(enabled=True).save() self.post_course_update() self.assertFalse(mock_push_update.called)
def push_notification_enabled(): """ Returns whether the push notification feature is enabled. """ return PushNotificationConfig.is_enabled()