Exemplo n.º 1
0
    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
Exemplo n.º 2
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
Exemplo n.º 3
0
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
    })
Exemplo n.º 4
0
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
        })
Exemplo n.º 5
0
 def handle(self, *args, **options):
     email_healthchecks(run_healthchecks())
     print 'Done!'