Example #1
0
    def test_send_experiment_ending_email(self):
        send_experiment_ending_email(self.experiment)

        sent_email = mail.outbox[-1]

        self.assertEqual(
            sent_email.subject,
            "Delivery ending soon: Greatest Experiment 68.0 to 69.0 Nightly",
        )
        self.assertEqual(sent_email.content_subtype, "html")
        self.assertTrue(
            self.experiment.emails.filter(
                type=ExperimentConstants.EXPERIMENT_ENDS).exists())
        self.assertEqual(
            sent_email.recipients(),
            [self.experiment.owner.email, self.subscribing_user.email],
        )
        self.assertIn("May 11, 2019", sent_email.body)
Example #2
0
def send_period_ending_emails_task(experiment):
    # send experiment ending soon emails if end date is 5 days out
    if experiment.ending_soon:
        if not ExperimentEmail.objects.filter(
            experiment=experiment, type=ExperimentConstants.EXPERIMENT_ENDS
        ).exists():
            email.send_experiment_ending_email(experiment)
            logger.info("Sent ending email for Experiment: {}".format(experiment))
    # send enrollment ending emails if enrollment end
    # date is 5 days out
    if experiment.enrollment_end_date and experiment.enrollment_ending_soon:
        if not ExperimentEmail.objects.filter(
            experiment=experiment, type=ExperimentConstants.EXPERIMENT_PAUSES
        ).exists():
            email.send_enrollment_pause_email(experiment)
            logger.info(
                "Sent enrollment pause email for Experiment: {}".format(experiment)
            )