Example #1
0
    def test_send_state_changed_email(self, mock_send):
        self.admission.state = admission_state_choices.ACCEPTED
        self.admission._original_state = self.admission.state
        self.admission.save()
        admission.save_state_changed_and_send_email(self.admission)
        args = mock_send.call_args[1]

        self.assertEqual(_(self.admission.state),
                         args.get('data').get('subject').get('state'))
        self.assertEqual(_get_managers_mails(self.admission.formation),
                         args.get('data').get('template').get('mails'))
        self.assertEqual(self.admission.person_information.person.first_name,
                         args.get('data').get('template').get('first_name'))
        self.assertEqual(self.admission.person_information.person.last_name,
                         args.get('data').get('template').get('last_name'))
        self.assertEqual(self.admission.formation,
                         args.get('data').get('template').get('formation'))
        self.assertEqual(_(self.admission.state),
                         args.get('data').get('template').get('state'))
        self.assertEqual(
            self.admission.state_reason
            if self.admission.state_reason else "-",
            args.get('data').get('template').get('reason'))
        self.assertEqual(len(args.get('receivers')), 2)
        self.assertIsNone(args.get('attachment'))
Example #2
0
    def test_send_invoice_uploaded_email(self, mock_send):
        admission.send_invoice_uploaded_email(self.admission)
        args = mock_send.call_args[1]

        self.assertEqual({}, args.get('data').get('subject'))
        self.assertEqual(_get_managers_mails(self.admission.formation),
                         args.get('data').get('template').get('mails'))
        self.assertEqual(self.admission.formation.acronym,
                         args.get('data').get('template').get('formation'))
        self.assertEqual(len(args.get('receivers')), 2)
        self.assertIsNone(args.get('attachment'))
    def test_get_managers_mail_mail_missing(self):
        ed = EducationGroupFactory()
        EducationGroupYearFactory(education_group=ed)
        manager = PersonFactory(last_name="AAA", email="")
        manager_2 = PersonFactory(last_name="BBB", email="")
        cet = ContinuingEducationTrainingFactory(education_group=ed)
        PersonTrainingFactory(person=manager, training=cet)
        PersonTrainingFactory(person=manager_2, training=cet)
        admission = AdmissionFactory(formation=cet)
        expected_mails = "{}".format(manager_2.email)

        self.assertEqual(_get_managers_mails(admission.formation),
                         expected_mails)
Example #4
0
    def test_get_managers_mail(self):
        ed = EducationGroupFactory()
        EducationGroupYearFactory(education_group=ed,
                                  academic_year=create_current_academic_year())
        manager = PersonFactory(last_name="AAA")
        manager_2 = PersonFactory(last_name="BBB")
        cet = ContinuingEducationTrainingFactory(education_group=ed)
        ContinuingEducationTrainingManagerFactory(person=manager, training=cet)
        ContinuingEducationTrainingManagerFactory(person=manager_2,
                                                  training=cet)
        admission = AdmissionFactory(formation=cet)
        expected_mails = "{}{}{}".format(manager.email, _(" or "),
                                         manager_2.email)

        self.assertEqual(_get_managers_mails(admission.formation),
                         expected_mails)
Example #5
0
    def test_send_admission_submitted_email_to_participant(self, mock_send):
        admission.send_submission_email_to_participant(self.admission,
                                                       connected_user=None)
        args = mock_send.call_args[1]

        self.assertEqual({}, args.get('data').get('subject'))
        self.assertEqual(_get_managers_mails(self.admission.formation),
                         args.get('data').get('template').get('mails'))
        self.assertEqual(self.admission.formation.title,
                         args.get('data').get('template').get('formation'))
        self.assertEqual(self.admission.person_information.person.last_name,
                         args.get('data').get('template').get('name'))
        self.assertEqual(
            _get_formatted_admission_data(self.admission),
            args.get('data').get('template').get('admission_data'))
        self.assertEqual(len(args.get('receivers')), 2)
        self.assertIsNone(args.get('attachment'))