예제 #1
0
 def run(self, **kwargs):
     """Sends an e-mail to a new device assignee."""
     device = kwargs.get('device')
     if not device:
         raise SendWelcomeError(
             'Cannot send mail. Task did not receive a device; only kwargs: '
             '{}'.format(str(kwargs)))
     send_email.send_user_email(device, 'reminder_welcome')
예제 #2
0
 def run(self, **kwargs):
   """Sends an e-mail to a former device assignee, thanking them."""
   device = kwargs.get('device')
   if not device:
     raise SendThanksError(
         'Cannot send mail. Task did not receive a device; only kwargs: '
         '{}'.format(str(kwargs)))
   send_email.send_user_email(device, 'reminder_return_thanks')
예제 #3
0
    def tests_send_user_email(self, mock_render, mock_sendemail, mock_logging):
        """Test sending mail to users."""
        now = datetime.datetime.utcnow()
        last_week = now - datetime.timedelta(days=7)
        test_device = device_model.Device(serial_number='12345ABC',
                                          chrome_device_id='4815162342',
                                          assigned_user=loanertest.USER_EMAIL,
                                          assignment_date=last_week,
                                          due_date=now)
        test_device.put()
        mock_render.return_value = ('Fake title', 'Fake body.')

        send_email.config_model.Config.set(
            'img_banner_primary', 'https://button.site/banners/primary.png')
        send_email.config_model.Config.set('img_button_manage',
                                           'https://button.site/manage.png')

        send_email.send_user_email(test_device, 'test_reminder_template')
        assert mock_logging.info.called
        assert mock_sendemail.called
        assert mock_render.called
예제 #4
0
 def run(self, device=None):
     """Send an e-mail to the device assignee and remove reminder."""
     if not device:
         raise base_action.MissingDeviceError(
             'Cannot send mail. Task did not receive a device.')
     if not hasattr(device, 'next_reminder') or not device.next_reminder:
         raise base_action.BadDeviceError(
             'Cannot send mail without next_reminder on device with serial '
             '{}.'.format(device.serial_number))
     reminder_event = event_models.ReminderEvent.get(
         device.next_reminder.level)
     if not reminder_event:
         raise base_action.BadDeviceError(
             'Cannot send mail. There is no ReminderEvent entity for level '
             '{}.'.format(device.next_reminder.level))
     logging.info('Sending reminder at level %d to device %s.',
                  device.next_reminder.level, device.identifier)
     send_email.send_user_email(device, reminder_event.template)
     device.set_last_reminder(device.next_reminder.level)
     device.next_reminder = None
     device.put()
예제 #5
0
 def run(self, device=None):
     """Sends an e-mail to a new device assignee."""
     if not device:
         raise base_action.MissingDeviceError(
             'Cannot send mail. Task did not receive a device.')
     send_email.send_user_email(device, 'reminder_welcome')
예제 #6
0
 def run(self, device=None):
     """Sends an e-mail to a former device assignee, thanking them."""
     if not device:
         raise base_action.MissingDeviceError(
             'Cannot send mail. Task did not receive a device.')
     send_email.send_user_email(device, 'reminder_return_thanks', False)