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)
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
def test_should_send_no_message_if_the_sender_is_a_computer(self): self.fake_message.computer = True self.assertFalse(send_message(1))
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)
def test_should_send_the_message_if_not_at_daily_limit(self): send_message(1) self.assertTrue(self.send_mail.called)