示例#1
0
    def test_should_send_no_message_when_the_daily_limit_is_exceeded(self):
        too_many_messages = [None] * (self.daily_limit + 1)
        self.message_objects.filter.return_value = too_many_messages

        send_message(1)

        self.assertFalse(self.send_mail.called)
示例#2
0
    def send_message(self):
        """Send an e-mail notice about this message."""
        from messenger.tasks import send_message

        try:
            send_message.delay(self.pk)  # Async attempt.
        except (KeyError, error):
            log.info("Asynchronus e-mail send failed.", exc_info=True)
            send_message(self.pk)  # Syncrhonus
示例#3
0
 def test_should_send_no_message_if_the_sender_is_a_computer(self):
     self.fake_message.computer = True
     self.assertFalse(send_message(1))
示例#4
0
    def test_should_send_an_alert_when_the_daily_limit_is_reached(self):
        self.message_objects.filter.return_value = [None] * self.daily_limit

        send_message(1)

        self.assertTrue(self.send_mail.called)
示例#5
0
 def test_should_send_the_message_if_not_at_daily_limit(self):
     send_message(1)
     self.assertTrue(self.send_mail.called)