forked from GithubBackups/healthchecks
parent
aa7ef5e9bb
commit
67d11e8d40
@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Fix sendalerts to clear Profile.next_nag_date if all checks up
|
||||
- Fix the pause action to clear Profile.next_nag_date if all checks up
|
||||
- Fix the "Email Reports" screen to clear Profile.next_nag_date if all checks up
|
||||
- Fix the month boundary calculation in monthly reports (#497)
|
||||
|
||||
## v1.19.0 - 2021-02-03
|
||||
|
||||
|
@ -195,6 +195,10 @@ class Profile(models.Model):
|
||||
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
|
||||
}
|
||||
|
||||
boundaries = month_boundaries(months=3)
|
||||
# throw away the current month, keep two previous months
|
||||
boundaries.pop()
|
||||
|
||||
ctx = {
|
||||
"checks": checks,
|
||||
"sort": self.sort,
|
||||
@ -204,7 +208,7 @@ class Profile(models.Model):
|
||||
"nag": nag,
|
||||
"nag_period": self.nag_period.total_seconds(),
|
||||
"num_down": num_down,
|
||||
"month_boundaries": month_boundaries(),
|
||||
"month_boundaries": boundaries,
|
||||
}
|
||||
|
||||
emails.report(self.user.email, ctx, headers)
|
||||
|
@ -1,12 +1,17 @@
|
||||
from datetime import timedelta as td
|
||||
from datetime import datetime, timedelta as td
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from django.core import mail
|
||||
from django.utils.timezone import now
|
||||
from django.utils.timezone import now, utc
|
||||
from hc.test import BaseTestCase
|
||||
from hc.api.models import Check
|
||||
|
||||
CURRENT_TIME = datetime(2020, 1, 15, tzinfo=utc)
|
||||
MOCK_NOW = Mock(return_value=CURRENT_TIME)
|
||||
|
||||
|
||||
class ProfileModelTestCase(BaseTestCase):
|
||||
@patch("hc.lib.date.timezone.now", MOCK_NOW)
|
||||
def test_it_sends_report(self):
|
||||
check = Check(project=self.project, name="Test Check")
|
||||
check.last_ping = now()
|
||||
@ -22,6 +27,12 @@ class ProfileModelTestCase(BaseTestCase):
|
||||
self.assertEqual(message.subject, "Monthly Report")
|
||||
self.assertIn("Test Check", message.body)
|
||||
|
||||
html, _ = message.alternatives[0]
|
||||
self.assertNotIn("Jan. 2020", html)
|
||||
self.assertIn("Dec. 2019", html)
|
||||
self.assertIn("Nov. 2019", html)
|
||||
self.assertNotIn("Oct. 2019", html)
|
||||
|
||||
def test_it_skips_report_if_no_pings(self):
|
||||
check = Check(project=self.project, name="Test Check")
|
||||
check.save()
|
||||
|
Loading…
x
Reference in New Issue
Block a user