From b8aabd711cdf981bd7a6b415ba2bac262dc4030e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sun, 15 Jan 2017 13:07:19 +0200 Subject: [PATCH] Testcase for sendreports --- hc/api/tests/test_sendreports.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 hc/api/tests/test_sendreports.py diff --git a/hc/api/tests/test_sendreports.py b/hc/api/tests/test_sendreports.py new file mode 100644 index 00000000..c17e1cd1 --- /dev/null +++ b/hc/api/tests/test_sendreports.py @@ -0,0 +1,20 @@ +from datetime import timedelta + +from django.utils import timezone +from hc.api.management.commands.sendreports import Command +from hc.api.models import Check +from hc.test import BaseTestCase + + +class SendAlertsTestCase(BaseTestCase): + + def test_it_sends_report(self): + # Make alice eligible for reports + self.alice.date_joined = timezone.now() - timedelta(days=365) + self.alice.save() + + check = Check(user=self.alice, last_ping=timezone.now()) + check.save() + + sent = Command().handle_one_run() + self.assertEqual(sent, 1)