Exemple #1
0
    def test_skip_if_no_patients(self):
        """Skip sending the email if there are not patients for this date."""

        appt_date = datetime.date.today() + datetime.timedelta(days=5)
        confirmed = self.create_confirmed_notification(self.test_patient, appt_date)

        # run email job
        from aremind.apps.reminders.app import daily_email_callback
        daily_email_callback(self.router)

        self.assertEqual(len(mail.outbox), 0)
Exemple #2
0
    def test_skip_if_no_patients(self):
        """Skip sending the email if there are not patients for this date."""

        appt_date = datetime.date.today() + datetime.timedelta(days=5)
        confirmed = self.create_confirmed_notification(self.test_patient,
                                                       appt_date)

        # run email job
        from aremind.apps.reminders.app import daily_email_callback
        daily_email_callback(self.router)

        self.assertEqual(len(mail.outbox), 0)
Exemple #3
0
    def test_sending_mail(self):
        """Test email goes out the contacts in the daily report group."""

        appt_date = datetime.date.today() + datetime.timedelta(days=7) # Default for email
        confirmed = self.create_confirmed_notification(self.test_patient, appt_date)

        # run email job
        daily_email_callback(self.router)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertTrue(self.test_contact.email in message.to)
Exemple #4
0
    def test_sending_mail(self):
        """Test email goes out the contacts in the daily report group."""

        appt_date = datetime.date.today() + datetime.timedelta(
            days=7)  # Default for email
        confirmed = self.create_confirmed_notification(self.test_patient,
                                                       appt_date)

        # run email job
        daily_email_callback(self.router)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertTrue(self.test_contact.email in message.to)
Exemple #5
0
    def test_skip_blank_emails(self):
        """Test handling contacts with blank email addresses."""
        appt_date = datetime.date.today() + datetime.timedelta(days=7) # Default for email
        confirmed = self.create_confirmed_notification(self.test_patient, appt_date)

        blank_contact = self.create_contact(data={'email': ''})
        self.group.contacts.add(blank_contact)

        # run email job
        from aremind.apps.reminders.app import daily_email_callback
        daily_email_callback(self.router)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertEqual(len(message.to), 1)
Exemple #6
0
    def test_appointment_date(self):
        """Test email contains info for the appointment date."""
        # Default for email
        appt_date = datetime.date.today() + datetime.timedelta(days=7) 
        self.create_confirmed_notification(self.test_patient, appt_date)
        self.create_unconfirmed_notification(self.other_patient, appt_date)

        # run email job
        from aremind.apps.reminders.app import daily_email_callback
        daily_email_callback(self.router)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertPatientInMessage(message, self.test_patient)
        self.assertPatientInMessage(message, self.other_patient)
        self.assertPatientNotInMessage(message, self.unrelated_patient)
Exemple #7
0
    def test_appointment_date(self):
        """Test email contains info for the appointment date."""
        # Default for email
        appt_date = datetime.date.today() + datetime.timedelta(days=7)
        self.create_confirmed_notification(self.test_patient, appt_date)
        self.create_unconfirmed_notification(self.other_patient, appt_date)

        # run email job
        from aremind.apps.reminders.app import daily_email_callback
        daily_email_callback(self.router)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertPatientInMessage(message, self.test_patient)
        self.assertPatientInMessage(message, self.other_patient)
        self.assertPatientNotInMessage(message, self.unrelated_patient)
Exemple #8
0
    def test_skip_blank_emails(self):
        """Test handling contacts with blank email addresses."""
        appt_date = datetime.date.today() + datetime.timedelta(
            days=7)  # Default for email
        confirmed = self.create_confirmed_notification(self.test_patient,
                                                       appt_date)

        blank_contact = self.create_contact(data={'email': ''})
        self.group.contacts.add(blank_contact)

        # run email job
        from aremind.apps.reminders.app import daily_email_callback
        daily_email_callback(self.router)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertEqual(len(message.to), 1)
Exemple #9
0
    def test_changing_date(self):
        """Test changing appointment date via callback kwarg."""
        days = 2
        appt_date = datetime.date.today() + datetime.timedelta(days=days)
        confirmed = self.create_confirmed_notification(self.test_patient,
                                                       appt_date)
        unconfirmed = self.create_unconfirmed_notification(self.other_patient,
                                                           appt_date)

        # run email job
        from aremind.apps.reminders.app import daily_email_callback
        daily_email_callback(self.router, days=days)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertPatientInMessage(message, self.test_patient)
        self.assertPatientInMessage(message, self.other_patient)
        self.assertPatientNotInMessage(message, self.unrelated_patient)
Exemple #10
0
    def test_changing_date(self):
        """Test changing appointment date via callback kwarg."""
        days = 2
        appt_date = datetime.date.today() + datetime.timedelta(days=days)
        confirmed = self.create_confirmed_notification(self.test_patient,
                                                       appt_date)
        unconfirmed = self.create_unconfirmed_notification(
            self.other_patient, appt_date)

        # run email job
        from aremind.apps.reminders.app import daily_email_callback
        daily_email_callback(self.router, days=days)

        self.assertEqual(len(mail.outbox), 1)
        message = mail.outbox[0]
        self.assertPatientInMessage(message, self.test_patient)
        self.assertPatientInMessage(message, self.other_patient)
        self.assertPatientNotInMessage(message, self.unrelated_patient)
Exemple #11
0
 def run(self):
     router = Router()
     daily_email_callback(router)