def test_no_recipients(self): """If there are no recipients, no email is sent""" # The mailing list gets created in data migrations. For the purposes of # this test, we delete that. MailingList.objects.filter(name=MAILINGLIST).delete() email_healthchecks(run_healthchecks()) assert len(mail.outbox) == 0
def test_with_recipients(self): """If there are recipients, then email is sent""" # Note: The mailing list should get created in data migrations. ml = MailingList.objects.get(name=MAILINGLIST) ml.members = u'*****@*****.**' ml.save() email_healthchecks(run_healthchecks()) assert len(mail.outbox) == 1 assert mail.outbox[0].to == [u'*****@*****.**'] # Severity should be RED ALERT since there's no hb items--at least # one of the checks should be all like, "OMG! RED ALERT!" assert 'RED ALERT' in mail.outbox[0].subject
def hb_healthcheck(request): """View for viewing healthchecks and kicking off a healthcheck email""" ml_recipients = get_recipients(MAILINGLIST) results = run_healthchecks() # If they did a POST, it means they want to email the results to the # mailing list. if request.method == 'POST': email_healthchecks(results) return render(request, 'analytics/analyzer/hb_healthcheck.html', { 'results': results, 'MAILINGLIST': MAILINGLIST, 'ml_recipients': ml_recipients, 'severity_name': SEVERITY })
def hb_healthcheck(request): """View for viewing healthchecks and kicking off a healthcheck email""" ml_recipients = get_recipients(MAILINGLIST) results = run_healthchecks() # If they did a POST, it means they want to email the results to the # mailing list. if request.method == 'POST': email_healthchecks(results) return render( request, 'analytics/analyzer/hb_healthcheck.html', { 'results': results, 'MAILINGLIST': MAILINGLIST, 'ml_recipients': ml_recipients, 'severity_name': SEVERITY })
def handle(self, *args, **options): email_healthchecks(run_healthchecks()) print 'Done!'