Ejemplo n.º 1
0
    def when_feature_send_mail_to_users_enabled_and_not_offer_booking_email_sends_only_to_administration(
            self):
        # Given
        num_bookings = 5
        bookings = create_mocked_bookings(num_bookings, None)
        mocked_send_email = Mock()
        return_value = Mock()
        return_value.status_code = 200
        mocked_send_email.return_value = return_value

        # When
        with patch('utils.mailing.feature_send_mail_to_users_enabled',
                   return_value=True), patch(
                       'domain.user_emails.make_batch_cancellation_email',
                       return_value={'Html-part':
                                     ''}) as make_cancellation_email:
            # When
            send_batch_cancellation_email_to_offerer(bookings,
                                                     'event_occurrence',
                                                     mocked_send_email)

        # Then
        make_cancellation_email.assert_called_once_with(
            bookings, 'event_occurrence')

        mocked_send_email.assert_called_once()
        args = mocked_send_email.call_args
        assert args[1]['data']['To'] == '*****@*****.**'
Ejemplo n.º 2
0
    def when_feature_send_mail_to_users_disabled_sends_email_to_pass_culture_dev(
            self):
        # Given
        num_bookings = 5
        bookings = create_mocked_bookings(num_bookings, '*****@*****.**')
        mocked_send_email = Mock()
        return_value = Mock()
        return_value.status_code = 200
        mocked_send_email.return_value = return_value

        # When
        with patch('utils.mailing.feature_send_mail_to_users_enabled',
                   return_value=False), patch(
                       'domain.user_emails.make_batch_cancellation_email',
                       return_value={'Html-part':
                                     ''}) as make_cancellation_email:
            # When
            send_batch_cancellation_email_to_offerer(bookings, 'stock',
                                                     mocked_send_email)

        # Then
        mocked_send_email.assert_called_once()
        args = mocked_send_email.call_args
        assert args[1]['data']['To'] == '*****@*****.**'
        assert 'This is a test' in args[1]['data']['Html-part']
Ejemplo n.º 3
0
    def when_called_calls_send_offerer_driven_cancellation_email_to_user_for_every_booking(
            self,
            mocked_send_warning_to_beneficiary_after_pro_booking_cancellation):
        # Given
        num_bookings = 6
        bookings = create_mocked_bookings(num_bookings, "*****@*****.**")
        calls = [call(booking) for booking in bookings]

        # When
        send_batch_cancellation_emails_to_users(bookings)

        # Then
        mocked_send_warning_to_beneficiary_after_pro_booking_cancellation.assert_has_calls(
            calls)
Ejemplo n.º 4
0
    def test_sends_to_offerer_administration(
            self,
            retrieve_offerer_bookings_recap_email_data_after_offerer_cancellation
    ):
        # Given
        num_bookings = 5
        bookings = create_mocked_bookings(num_bookings, "*****@*****.**")

        # When
        send_offerer_bookings_recap_email_after_offerer_cancellation(bookings)

        # Then
        retrieve_offerer_bookings_recap_email_data_after_offerer_cancellation.assert_called_once_with(
            bookings)
        assert mails_testing.outbox[0].sent_data["Mj-TemplateID"] == 1116333
Ejemplo n.º 5
0
    def when_feature_send_mail_to_users_enabled_and_offerer_email_is_missing_sends_only_to_administration(
            self, feature_send_mail_to_users_enabled,
            retrieve_offerer_bookings_recap_email_data_after_offerer_cancellation
    ):
        # Given
        num_bookings = 5
        bookings = create_mocked_bookings(num_bookings, None)
        recipients = "*****@*****.**"
        mocked_send_email = Mock()

        # When
        send_offerer_bookings_recap_email_after_offerer_cancellation(
            bookings, mocked_send_email)

        # Then
        retrieve_offerer_bookings_recap_email_data_after_offerer_cancellation.assert_called_once_with(
            bookings, recipients)
        mocked_send_email.assert_called_once_with(
            data={"Mj-TemplateID": 1116333})
Ejemplo n.º 6
0
    def when_called_calls_send_offerer_driven_cancellation_email_to_user_for_every_booking(
            self):
        # Given
        mocked_send_email = Mock()
        return_value = Mock()
        return_value.status_code = 200
        mocked_send_email.return_value = return_value
        num_bookings = 6
        bookings = create_mocked_bookings(num_bookings, '*****@*****.**')
        calls = [call(booking, mocked_send_email) for booking in bookings]

        # When
        with patch(
                'domain.user_emails.send_offerer_driven_cancellation_email_to_user'
        ) as send_cancellation_email_one_user, patch(
                'domain.user_emails.make_offerer_driven_cancellation_email_for_user',
                return_value={'Html-part': ''}), patch(
                    'utils.mailing.feature_send_mail_to_users_enabled',
                    return_value=True):
            send_batch_cancellation_emails_to_users(bookings,
                                                    mocked_send_email)

        # Then
        send_cancellation_email_one_user.assert_has_calls(calls)