Exemplo n.º 1
0
    def test_disabled(self):
        self.user.preferences.user_submit_reminder_notifications = False
        self.user.save()

        sent = user_submit_reminder_notification(self.user,
                                                 self.submission_period)
        self.assertFalse(sent)
Exemplo n.º 2
0
def send_submission_reminders(submission_period_id):
    if not submission_period_id:
        app.logger.error('No submission period id for submission reminders!')
        return False

    try:
        league_id = select_league_id_for_round(submission_period_id)
        league = select_league(
            league_id,
            exclude_properties=['votes', '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_submitted:
            app.logger.debug('User has not submitted! Notifying.',
                             extra={'user': str(user.id)})
            user_submit_reminder_notification(user, submission_period)
        return True

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

        self.assertTrue(sent)
        email.assert_called_once_with(self.user, self.submission_period)
Exemplo n.º 4
0
 def test_no_user(self):
     sent = user_submit_reminder_notification(None, self.submission_period)
     self.assertFalse(sent)
Exemplo n.º 5
0
 def test_no_submission_period(self):
     sent = user_submit_reminder_notification(self.user, None)
     self.assertFalse(sent)