diff --git a/hc/accounts/tests/test_profile.py b/hc/accounts/tests/test_profile.py index e3cdd6e6..43dc2452 100644 --- a/hc/accounts/tests/test_profile.py +++ b/hc/accounts/tests/test_profile.py @@ -2,6 +2,7 @@ from django.core import mail from hc.test import BaseTestCase from hc.accounts.models import Profile +from hc.api.models import Check class LoginTestCase(BaseTestCase): @@ -41,3 +42,17 @@ class LoginTestCase(BaseTestCase): profile = Profile.objects.for_user(self.alice) self.assertEqual(profile.api_key, "") + + def test_it_sends_report(self): + check = Check(name="Test Check", user=self.alice) + check.save() + + profile = Profile.objects.for_user(self.alice) + profile.send_report() + + # And an email should have been sent + self.assertEqual(len(mail.outbox), 1) + message = mail.outbox[0] + + self.assertEqual(message.subject, 'Monthly Report') + self.assertIn("Test Check", message.body) diff --git a/hc/api/models.py b/hc/api/models.py index 6edad11c..80559dcb 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -61,6 +61,9 @@ class Check(models.Model): def url(self): return settings.PING_ENDPOINT + str(self.code) + def log_url(self): + return settings.SITE_ROOT + reverse("hc-log", args=[self.code]) + def email(self): return "%s@%s" % (self.code, settings.PING_EMAIL_DOMAIN) diff --git a/templates/emails/alert-body-html.html b/templates/emails/alert-body-html.html index ba621494..d4ed9f2d 100644 --- a/templates/emails/alert-body-html.html +++ b/templates/emails/alert-body-html.html @@ -41,9 +41,9 @@
{{ check.url }}
- {{ check.url }}
-