def handle(self, *args, **kwargs):
     """
     Send all pending habit data collection emails. This command should be
     called on a cronjob once a day (probably at the start of the working
     day).
     """
     for habit in Habit.objects.filter(send_data_collection_emails=True):
         send_data_collection_email(habit)
Beispiel #2
0
    def test_disable_send_data_collection_email(self):
        self.h.send_data_collection_emails = False

        result = send_data_collection_email(self.h)

        self.assertIsNone(result)
        self.assertEqual(len(mail.outbox), 0)
Beispiel #3
0
    def test_send_data_collection_email_for_archived_habit(self):
        self.h.archived = True

        result = send_data_collection_email(self.h)

        self.assertIsNone(result)
        self.assertEqual(len(mail.outbox), 0)
Beispiel #4
0
    def test_send_data_collection_email_for_archived_habit(self):
        self.h.archived = True

        result = send_data_collection_email(self.h)

        self.assertIsNone(result)
        self.assertEqual(len(mail.outbox), 0)
Beispiel #5
0
    def test_disable_send_data_collection_email(self):
        self.h.send_data_collection_emails = False

        result = send_data_collection_email(self.h)

        self.assertIsNone(result)
        self.assertEqual(len(mail.outbox), 0)
Beispiel #6
0
def test_send_data_collection_email(self, fixture):
    resolution, today, should_send = fixture
    today_date = helpers.parse_isodate(today)

    self.h.resolution = resolution
    result = send_data_collection_email(self.h, today=today_date)

    if should_send:
        self.assertIsNotNone(result)
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue('Let us know' in mail.outbox[0].subject)
    else:
        self.assertIsNone(result)
        self.assertEqual(len(mail.outbox), 0)
Beispiel #7
0
def test_send_data_collection_email(self, fixture):
    resolution, today, should_send = fixture
    today_date = helpers.parse_isodate(today)

    self.h.resolution = resolution
    result = send_data_collection_email(self.h, today=today_date)

    if should_send:
        self.assertIsNotNone(result)
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue('Let us know' in mail.outbox[0].subject)
    else:
        self.assertIsNone(result)
        self.assertEqual(len(mail.outbox), 0)