Beispiel #1
0
    def test_disabled(self):
        self.user.preferences.user_vote_reminder_notifications = False
        self.user.save()

        sent = user_vote_reminder_notification(self.user,
                                               self.submission_period)
        self.assertFalse(sent)
def send_vote_reminders(submission_period_id):
    if not submission_period_id:
        app.logger.error('No submission period id for vote reminders!')
        return False

    try:
        league_id = select_league_id_for_round(submission_period_id)
        league = select_league(
            league_id, exclude_properties=['scoreboard', 'invited_users'])
        submission_period = next((r for r in league.submission_periods
                                  if r.id == submission_period_id), None)
        for user in submission_period.have_not_voted:
            app.logger.debug('User has not voted! Notifying.',
                             extra={'user': str(user.id)})
            user_vote_reminder_notification(user, submission_period)
        return True

    except Exception as e:
        app.logger.exception('Error while sending vote reminders!',
                             exc_info=e,
                             extra={'round': submission_period_id})
        return False
Beispiel #3
0
    def test_send(self, messenger, email):
        sent = user_vote_reminder_notification(self.user,
                                               self.submission_period)

        self.assertTrue(sent)
        email.assert_called_once_with(self.user, self.submission_period)
Beispiel #4
0
 def test_no_user(self):
     sent = user_vote_reminder_notification(None, self.submission_period)
     self.assertFalse(sent)
Beispiel #5
0
 def test_no_submission_period(self):
     sent = user_vote_reminder_notification(self.user, None)
     self.assertFalse(sent)