django.core.mail.outbox

Here are the examples of the python api django.core.mail.outbox taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

181 Examples 7

Example 1

Project: django-celery-email Source File: tests.py
    def test_sending_html_email(self):
        msg = EmailMultiAlternatives('test', 'Testing with Celery! w00t!!', '[email protected]',
                                     ['[email protected]'])
        html = '<p>Testing with Celery! w00t!!</p>'
        msg.attach_alternative(html, 'text/html')
        [result] = msg.send()
        self.assertEqual(result.get(), 1)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, 'test')
        self.assertEqual(mail.outbox[0].alternatives, [(html, 'text/html')])

Example 2

Project: tendenci Source File: test_ticket_submission.py
    def test_create_ticket_direct(self):
        email_count = len(mail.outbox)
        ticket_data = dict(queue=self.queue_public, **self.ticket_data)
        ticket = Ticket.objects.create(**ticket_data)
        self.assertEqual(ticket.ticket_for_url, "q1-%s" % ticket.id)
        self.assertEqual(email_count, len(mail.outbox))

Example 3

Project: colab Source File: test_password_reset.py
Function: test_email_not_found
    def test_email_not_found(self):
        """
        Error is raised if the provided e-mail address isn't verified to an
        existing user account
        """
        data = {
            "email": "[email protected]",
        }
        response = self.client.post("/account/password_reset/", data)
        self.assertEquals(response.status_code, 200)
        # @@@ instead of hard-coding this error message rely on a error key
        # defined in the form where the site developer would override this
        # error message.
        self.assertContains(response, "Email address not verified for any user account")
        self.assertEquals(len(mail.outbox), 0)

Example 4

Project: django-compositepks Source File: views.py
Function: test_confirm_start
    def _test_confirm_start(self):
        # Start by creating the email
        response = self.client.post('/password_reset/', {'email': '[email protected]'})
        self.assertEquals(response.status_code, 302)
        self.assertEquals(len(mail.outbox), 1)
        return self._read_signup_email(mail.outbox[0])

Example 5

Project: django-libs Source File: email_tests.py
    def test_cc_and_bcc(self):
        send_email(
            None,
            {},
            'subject.html',
            'html_email.html',
            '[email protected]',
            ['[email protected]'],
            cc=['[email protected]'],
            bcc=['[email protected]']
        )
        email = mail.outbox[0]
        self.assertEqual(['[email protected]'], email.cc)
        self.assertEqual(['[email protected]'], email.bcc)

Example 6

Project: web Source File: test_views.py
Function: test_registration
    def testRegistration(self):
        """Test that a registration is successful and that an activation email
        is sent."""
        response = self.client.post(self.registration_url, {
            'username': 'testuser',
            'password1': 'testpass',
            'password2': 'testpass',
        })
        self.assertRedirects(response, '/accounts/register/complete/')
        self.assertTrue(User.objects.filter(username='testuser').exists())
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, '[studentenportal.ch] Aktivierung')

Example 7

Project: badgr-server Source File: tests.py
Function: test_create_user
    def test_create_user(self):
        user_data = {
            'first_name': 'Test',
            'last_name': 'User',
            'email': '[email protected]',
            'password': '123456'
        }

        response = self.client.post('/v1/user/profile', user_data)

        self.assertEqual(response.status_code, 201)
        self.assertEqual(len(mail.outbox), 1)

Example 8

Project: dojopuzzles Source File: view_test.py
    def test_deve_enviar_email_com_dados_do_formulario_preenchido(self):
        """
        Preenchendo o formulário para contato deve enviar e-mail para o destinatário adequado.
        """
        self.assertEqual(len(mail.outbox), 0)
        dados_formulario = {'nome': 'Usuario Teste',
                            'email': '[email protected]',
                            'assunto': 'CONTATO',
                            'mensagem': 'Esta mensagem de teste', }
        response = self.client.post(reverse('contribua'), dados_formulario)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].body, 'Esta mensagem de teste')
        self.assertEqual(mail.outbox[0].subject, 'DojoPuzzles.com - Contato realizado através do site')
        self.assertEqual(mail.outbox[0].from_email, '[email protected]')
        self.assertEqual(mail.outbox[0].to, ['[email protected]'])
        self.assertRedirects(response, reverse('contribuicao-recebida'))

Example 9

Project: scielo-manager Source File: tests_notifications.py
Function: test_each_action
    @override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, CELERY_ALWAYS_EAGER=True, BROKER_BACKEND='memory')
    def test_each_action(self):
        email_count = 0
        for action in self.ACTIONS:
            # with
            expected_subject = self._make_subject(action)
            email_count += 1
            # when
            result = notifications.issue_board_replica(issue=self.issue, action=action)
            # then
            self.assertTrue(result)
            self.assertEqual(len(mail.outbox), email_count)
            new_email = mail.outbox[-1]
            self.assertEqual(new_email.subject, expected_subject)
            self.assertEqual(len(self.expected_recipients), len(new_email.to))
            for recipient in self.expected_recipients:
                self.assertIn(recipient, new_email.to)

Example 10

Project: django-dbbackup Source File: test_utils.py
Function: test_raise
    @patch('dbbackup.settings.SEND_EMAIL', False)
    def test_raise(self):
        def func():
            raise Exception('Foo')
        with self.assertRaises(Exception):
            utils.email_uncaught_exception(func)()
        self.assertEqual(len(mail.outbox), 0)

Example 11

Project: django-organizations Source File: test_backends.py
    def test_send_reminder(self):
        InvitationBackend().send_reminder(self.pending_user)
        self.assertEqual(1, len(mail.outbox))
        InvitationBackend().send_reminder(self.user)
        self.assertEqual(1, len(mail.outbox))  # User is active
        mail.outbox = []

Example 12

Project: hawkpost Source File: tests.py
    def test_send_when_group_is_defined(self):
        settings.CELERY_ALWAYS_EAGER = True
        for i in range(4):
            create_and_login_user(self.client)
        last_user = create_and_login_user(self.client)
        group = Group.objects.create(name="Test Group")
        group.user_set.add(last_user)
        notification = create_notification(sent=False, group=group)
        enqueue_email_notifications(notification.id, notification.send_to.id)
        self.assertEqual(len(mail.outbox), 1)

Example 13

Project: splunk-webframework Source File: views.py
Function: test_email_not_found
    def test_email_not_found(self):
        "Error is raised if the provided email address isn't currently registered"
        response = self.client.get('/password_reset/')
        self.assertEqual(response.status_code, 200)
        response = self.client.post('/password_reset/', {'email': '[email protected]'})
        self.assertContainsEscaped(response, PasswordResetForm.error_messages['unknown'])
        self.assertEqual(len(mail.outbox), 0)

Example 14

Project: django-le-social Source File: tests.py
Function: test_activate
    def test_activate(self):
        url = reverse('registration_register')
        response = self.client.post(url, self.valid_data)

        self.assertFalse(User.objects.get().is_active)
        url = mail.outbox[0].body.split('testserver')[1].split('\n')[0]
        response = self.client.get(url, follow=True)
        self.assertContains(response, "Account successfully activated")
        self.assertEqual(len(response.redirect_chain), 1)

Example 15

Project: Misago Source File: test_auth_api.py
    def test_submit_invalid(self):
        """request change password form link api errors for invalid email"""
        response = self.client.post(self.link, data={'email': '[email protected]'})
        self.assertContains(response, 'not_found', status_code=400)

        self.assertTrue(not mail.outbox)

Example 16

Project: django-nonrel Source File: views.py
Function: test_confirm_start
    def _test_confirm_start(self):
        # Start by creating the email
        response = self.client.post('/password_reset/', {'email': '[email protected]'})
        self.assertEqual(response.status_code, 302)
        self.assertEqual(len(mail.outbox), 1)
        return self._read_signup_email(mail.outbox[0])

Example 17

Project: django-invitations Source File: tests.py
    @freeze_time('2015-07-30 12:00:06')
    def test_valid_form_submission(self):
        self.client.login(username='flibble', password='password')
        resp = self.client.post(
            reverse('invitations:send-invite'), {'email': '[email protected]'})
        invitation = Invitation.objects.get(email='[email protected]')

        self.assertEqual(resp.status_code, 200)
        self.assertIn('success_message', resp.context_data.keys())

        self.assertEqual(invitation.sent, datetime.datetime.now())
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to[0], '[email protected]')
        self.assertIn('Invitation to join example.com', mail.outbox[0].subject)
        url = re.search(
            "(?P<url>/invitations/[^\s]+)", mail.outbox[0].body).group("url")
        self.assertEqual(url, reverse(
            'invitations:accept-invite', kwargs={'key': invitation.key}))

Example 18

Project: django-secure-login Source File: tests.py
    @override_settings(SECURE_LOGIN_ON_FAIL=["secure_login.on_fail.email_user", ])
    def test_email_sent_on_wrong_password(self):
        username = "hello"
        password = "hellohello"
        user = User.objects.create(username=username)
        user.set_password(password)
        user.save()

        self.assertFalse(
            authenticate(username=username, password=password + "1"))
        self.assertEqual(len(mail.outbox), 1)

Example 19

Project: vumi-go Source File: tests.py
    def test_send_scheduled_account_summary_task(self):
        user_account = self.user_helper.get_user_account()
        user_account.email_summary = u'daily'
        user_account.save()

        send_scheduled_account_summary('daily')
        send_scheduled_account_summary('weekly')

        [daily] = mail.outbox
        self.assertEqual(daily.subject, 'Vumi Go Account Summary')

        user_account.email_summary = u'weekly'
        user_account.save()

        send_scheduled_account_summary('daily')
        send_scheduled_account_summary('weekly')

        [daily, weekly] = mail.outbox
        self.assertEqual(weekly.subject, 'Vumi Go Account Summary')

Example 20

Project: django-cms Source File: test_templatetags.py
    def test_get_page_by_untyped_arg_dict_fail_debug(self):
        with self.settings(DEBUG=True):
            request = self.get_request('/')
            self.assertRaises(Page.DoesNotExist,
                              _get_page_by_untyped_arg, {'pk': 1003}, request, 1
            )
            self.assertEqual(len(mail.outbox), 0)

Example 21

Project: wagtail Source File: test_account_management.py
    def test_password_reset_view_post_unknown_email(self):
        """
        This posts an unknown email address to the password reset view and
        checks that the password reset form raises a validation error
        """
        post_data = {
            'email': '[email protected]',
        }
        response = self.client.post(reverse('wagtailadmin_password_reset'), post_data)

        # Check that the user wasn't redirected
        self.assertEqual(response.status_code, 200)

        # Check that a validation error was raised
        self.assertTrue('__all__' in response.context['form'].errors.keys())
        self.assertTrue("This email address is not recognised." in response.context['form'].errors['__all__'])

        # Check that an email was not sent
        self.assertEqual(len(mail.outbox), 0)

Example 22

Project: sublimall-server Source File: tests.py
    def test_confirmation_mail(self):
        """
        Registration must send an email with validation link
        """
        data = {
            'email': '[email protected]',
            'email2': '[email protected]',
            'password': 'foobar123',
            'password2': 'foobar123'
        }
        self.c.post(reverse('registration'), data)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].to, ['[email protected]'])

        member = Member.objects.get(email=data.get('email'))

        validation = '%s/%s' % (
            member.id, member.registration_key) in mail.outbox[0].body
        self.assertTrue(validation)

Example 23

Project: pretix Source File: test_event.py
    def test_no_orders_from_user(self):
        Order.objects.create(
            code='DUMMY1', status=Order.STATUS_PENDING, event=self.event,
            email='[email protected]', datetime=now(), expires=now(),
            total=0,
        )
        mail.outbox = []
        url = '/{}/{}/resend/'.format(self.orga.slug, self.event.slug)
        resp = self.client.post(url, data={'email': '[email protected]'})

        self.assertEqual(resp.status_code, 302)
        self.assertEqual(len(mail.outbox), 0)

Example 24

Project: coursys Source File: testcase.py
    def _pre_setup(self):
        """Disable transaction methods, and clear some globals."""
        # Repeat stuff from TransactionTestCase, because I'm not calling its
        # _pre_setup, because that would load fixtures again.
        cache.cache.clear()
        settings.TEMPLATE_DEBUG = settings.DEBUG = False


        self.client = self.client_class()
        #self._fixture_setup()
        self._urlconf_setup()
        mail.outbox = []

        # Clear site cache in case somebody's mutated Site objects and then
        # cached the mutated stuff:
        from django.contrib.sites.models import Site
        Site.objects.clear_cache()

Example 25

Project: django-email-log Source File: tests.py
    def test_send_messages(self):
        sent = self.send_mail(fail_silently=False, **self.plain_args)
        self.assertEqual(sent, 1)
        self.assertEqual(len(mail.outbox), 1)
        email = Email.objects.get()
        self.assertTrue(email.ok)
        self.assertEqual(email.recipients, "[email protected]")
        self.assertSequenceEqual(mail.outbox[0].to, ["[email protected]"])
        for message in (email, mail.outbox[0]):
            self.assertEqual(message.from_email, "[email protected]")
            self.assertEqual(message.subject, "Subject line")
            self.assertEqual(message.body, "Message body")

Example 26

Project: django-registration Source File: base.py
Function: test_registration
    def test_registration(self):
        """
        Registration creates a new inactive account and sends an
        activation email.

        """
        with self.assertSignalSent(signals.user_registered):
            super(ActivationTestCase, self).test_registration()

        new_user = self.user_model.objects.get(**self.user_lookup_kwargs)

        # New user must not be active.
        self.assertFalse(new_user.is_active)

        # An activation email was sent.
        self.assertEqual(len(mail.outbox), 1)

Example 27

Project: wger Source File: test_submitted_image.py
Function: accept
    def accept(self, fail=False):
        '''
        Helper function
        '''
        image = ExerciseImage.objects.get(pk=3)
        self.assertEqual(image.status, ExerciseImage.STATUS_PENDING)
        response = self.client.get(reverse('exercise:image:accept', kwargs={'pk': 3}))
        image = ExerciseImage.objects.get(pk=3)
        self.assertEqual(response.status_code, 302)

        if not fail:
            self.assertEqual(image.status, ExerciseImage.STATUS_ACCEPTED)
            response = self.client.get(response['Location'])
            self.assertEqual(response.status_code, 200)
            self.assertEqual(len(mail.outbox), 0)
        else:
            self.assertEqual(image.status, ExerciseImage.STATUS_PENDING)
            self.assertEqual(len(mail.outbox), 0)

Example 28

Project: SmartElect Source File: test_auditor.py
    def notifications_sent_test(self):
        # subscribers should be notified about discrepancies
        audit_sms.delay()
        # discrepancies found (5)
        # send email to each of the 3 subscribers
        self.assertEqual(len(mail.outbox), 3)
        # auditor second run
        audit_sms.delay()
        # no new discrepancies found
        # no new emails added to the outbox
        self.assertEqual(len(mail.outbox), 3)

Example 29

Project: django-ninecms Source File: tests_no_content.py
    def test_command_check_updates(self):
        """ Test command check updates
        :return: None
        """
        call_command('check_updates')
        with Capturing() as updates:
            pip.main(['list', '--outdated', '--retries', '1'])
        # noinspection PyUnresolvedReferences
        n = len(mail.outbox)
        if not updates:
            self.assertEqual(n, 0)  # pragma: nocover
        else:
            self.assertEqual(n, 1)  # pragma: nocover

Example 30

Project: pytest-django Source File: plugin.py
@pytest.fixture(autouse=True, scope='function')
def _django_clear_outbox(django_test_environment):
    """Clear the django outbox, internal to pytest-django."""
    if django_settings_is_configured():
        from django.core import mail
        del mail.outbox[:]

Example 31

Project: django-userena Source File: tests_models.py
Function: test_html_email
    def test_html_email(self):
        """
        If HTML emails are enabled, check outgoings emails are multipart and
        that different html and plain text templates are used
        """
        userena_settings.USERENA_HTML_EMAIL = True
        userena_settings.USERENA_USE_PLAIN_TEMPLATE = True

        new_user = UserenaSignup.objects.create_user(**self.user_info)

        # Reset configuration
        userena_settings.USERENA_HTML_EMAIL = False
        self.assertEqual(len(mail.outbox), 1)
        self.assertTrue(text_type(mail.outbox[0].message()).find("multipart/alternative")>-1)
        self.assertTrue(text_type(mail.outbox[0].message()).find("text/plain")>-1)
        self.assertTrue(text_type(mail.outbox[0].message()).find("text/html")>-1)
        self.assertTrue(text_type(mail.outbox[0].message()).find("<html>")>-1)
        self.assertTrue(text_type(mail.outbox[0].message()).find("<p>Thank you for signing up")>-1)
        self.assertFalse(mail.outbox[0].body.find("<p>Thank you for signing up")>-1)

Example 32

Project: django-celery-ses Source File: tests.py
    def test_no_delay(self):
        with no_delay: 
            msg = EmailMessage('title', 'body content', '[email protected]', ['[email protected]'])
            msg.send()
            
        self.assertEqual(len(mail.outbox), 1)

Example 33

Project: django-pytest Source File: conftest.py
Function: pytest_funcarg_client
def pytest_funcarg__client(request):
    '''Creates a test environment using the 'django_client' funcarg above, but
    also ensures the database is flushed after running each test.'''
    def setup():
        return request.getfuncargvalue('django_client')
    def teardown(client):
        call_command('flush', verbosity=0, interactive=False)
        mail.outbox = []
    return request.cached_setup(setup, teardown, "function")

Example 34

Project: django-post_office Source File: test_mail.py
    def test_send_bulk(self):
        """
        Ensure _send_bulk() properly sends out emails.
        """
        email = Email.objects.create(
            to=['[email protected]'], from_email='[email protected]',
            subject='send bulk', message='Message', status=STATUS.queued,
            backend_alias='locmem')
        sent_count, _ = _send_bulk([email])
        self.assertEqual(sent_count, 1)
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, 'send bulk')

Example 35

Project: dj-dynamic-forms Source File: test_actions.py
Function: test_send_email
    @override_settings(DYNAMIC_FORMS_EMAIL_RECIPIENTS=['[email protected]'])
    def test_send_email(self):
        self.assertTrue(self.form.is_valid())
        self.assertEqual(mail.outbox, [])
        dynamic_form_send_email(self.form_model, self.form)
        message = mail.outbox[0]
        self.assertEqual(message.subject, 'Form “Form” submitted')
        self.assertEqual(message.body, '''Hello,

you receive this e-mail because someone submitted the form “Form”.

DT: Aug. 29, 2013, 12:34 p.m.
Str: Some string to store
''')
        self.assertEqual(message.recipients(), ['[email protected]'])
        self.assertEqual(message.from_email, 'webmaster@localhost')

Example 36

Project: djoser Source File: tests.py
    def test_post_should_send_email_to_user_with_password_rest_link(self):
        user = create_user()
        data = {
            'email': user.email,
        }
        request = self.factory.post(data=data)

        response = self.view(request)

        self.assert_status_equal(response, status.HTTP_204_NO_CONTENT)
        self.assert_emails_in_mailbox(1)
        self.assert_email_exists(to=[user.email])
        site = djoser.utils.get_current_site(request)
        self.assertIn(site.domain, mail.outbox[0].body)
        self.assertIn(site.name, mail.outbox[0].body)

Example 37

Project: hue Source File: test_forms.py
    def test_custom_email_subject(self):
        data = {'email': '[email protected]'}
        form = PasswordResetForm(data)
        self.assertTrue(form.is_valid())
        # Since we're not providing a request object, we must provide a
        # domain_override to prevent the save operation from failing in the
        # potential case where contrib.sites is not installed. Refs #16412.
        form.save(domain_override='example.com')
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject, 'Custom password reset on example.com')

Example 38

Project: django-emailauth Source File: tests.py
    def prepare(self):
        user, user_email = self.createActiveUser() 

        client = Client()
        response = client.post('/resetpassword/', {
            'email': user_email.email,
        })

        self.assertRedirects(response,
            '/resetpassword/continue/user%40example.com/')

        email = mail.outbox[0]
        addr_re = re.compile(r'.*http://.*?(/\S*/)', re.UNICODE | re.MULTILINE)
        reset_url = addr_re.search(email.body).groups()[0]
        return reset_url, user_email

Example 39

Project: 1flow Source File: test_models.py
Function: test_close
    def test_close(self):

        closed_reason = u'closed for tests'

        self.feed.close(closed_reason)

        self.assertTrue(self.feed.closed)
        self.assertEquals(self.feed.closed_reason, closed_reason)
        self.assertFalse(self.feed.date_closed is None)

        global_feeds_checker()

        self.assertEquals(len(mail.outbox), 1)
        self.assertTrue(u'Reminder: 1 feed(s) closed in last'
                        in mail.outbox[0].subject)
        self.assertTrue(unicode(self.feed) in mail.outbox[0].body)

Example 40

Project: django-sharer Source File: tests.py
    def testShareFormSendsEmail(self):
        response = self.client.post(reverse("sharer_share"), {
            "recipient": "[email protected]",
            "sender": "[email protected]",
            "message": "This is a test!",
            "url": "http://www.dummy.com",
            "title": "Dummy Title",
        })

        self.assertRedirects(response, reverse("sharer_done"))
        self.assertEquals(len(mail.outbox), 1)

Example 41

Project: decode-Django Source File: forms.py
    def test_custom_email_subject(self):
        template_path = os.path.join(os.path.dirname(upath(__file__)), 'templates')
        with self.settings(TEMPLATE_DIRS=(template_path,)):
            data = {'email': '[email protected]'}
            form = PasswordResetForm(data)
            self.assertTrue(form.is_valid())
            # Since we're not providing a request object, we must provide a
            # domain_override to prevent the save operation from failing in the
            # potential case where contrib.sites is not installed. Refs #16412.
            form.save(domain_override='example.com')
            self.assertEqual(len(mail.outbox), 1)
            self.assertEqual(mail.outbox[0].subject, 'Custom password reset on example.com')

Example 42

Project: django-user-accounts Source File: test_views.py
    def test_post_authenticated_success(self):
        user = self.signup()
        data = {
            "password_current": "bar",
            "password_new": "new-bar",
            "password_new_confirm": "new-bar",
        }
        response = self.client.post(reverse("account_password"), data)
        self.assertRedirects(
            response,
            reverse(settings.ACCOUNT_PASSWORD_CHANGE_REDIRECT_URL),
            fetch_redirect_response=False
        )
        updated_user = User.objects.get(username=user.username)
        self.assertNotEqual(user.password, updated_user.password)
        self.assertEqual(len(mail.outbox), 1)

Example 43

Project: commcare-hq Source File: test_autopay.py
    @mock.patch.object(StripePaymentMethod, 'customer')
    @mock.patch.object(Charge, 'create')
    def test_when_stripe_fails_no_payment_record_exists(self, fake_create, fake_customer):
        fake_create.side_effect = Exception
        self._create_autopay_method(fake_customer)

        self.original_outbox_length = len(mail.outbox)
        self._run_autopay()
        self._assert_no_side_effects()

Example 44

Project: gallery Source File: tests.py
Function: test_invalid
    def test_invalid(self):
        """
        Test that invalid email addresses will be caught.
        """
        form_data = {'email': '[email protected]'}
        response = self.client.post(
            reverse('accounts:password_reset'), form_data)
        self.assertFormError(
            response, 'form', 'email',
            PasswordResetForm.error_messages['invalid_email'])
        self.assertEqual(len(mail.outbox), 0)

Example 45

Project: snowy Source File: tests.py
Function: test_create_pending
    def test_create_pending(self):
        """ Ensure creating a pending Consumer sends proper emails """
        # If it's pending we should have two messages in the outbox; one 
        # to the consumer and one to the site admins.
        if len(settings.ADMINS):
            self.assertEquals(len(mail.outbox), 2)
        else:
            self.assertEquals(len(mail.outbox), 1)

        expected = "Your API Consumer for example.com is awaiting approval."
        self.assertEquals(mail.outbox[0].subject, expected)

Example 46

Project: django-mailer Source File: tests.py
    def test_mail_managers(self):
        with self.settings(MAILER_EMAIL_BACKEND="django.core.mail.backends.locmem.EmailBackend", MANAGERS=(("Test", "[email protected]"),)):  # noqa
            mailer.mail_managers("Subject", "Manager Body")

            self.assertEqual(Message.objects.count(), 1)
            self.assertEqual(Message.objects.deferred().count(), 0)

            engine.send_all()

            self.assertEqual(Message.objects.count(), 0)
            self.assertEqual(Message.objects.deferred().count(), 0)

            self.assertEqual(len(mail.outbox), 1)
            sent = mail.outbox[0]

            # Default "plain text"
            self.assertEqual(sent.body, "Manager Body")
            self.assertEqual(sent.to, ["[email protected]"])

Example 47

Project: GAE-Bulk-Mailer Source File: testcases.py
Function: pre_setup
    def _pre_setup(self):
        """Performs any pre-test setup. This includes:

            * Flushing the database.
            * If the Test Case class has a 'fixtures' member, installing the
              named fixtures.
            * If the Test Case class has a 'urls' member, replace the
              ROOT_URLCONF with it.
            * Clearing the mail test outbox.
        """
        self.client = self.client_class()
        self._fixture_setup()
        self._urlconf_setup()
        mail.outbox = []

Example 48

Project: PyClassLessons Source File: test_forms.py
Function: test_non_existent_email
    def test_nonexistent_email(self):
        """
        Test nonexistent email address. This should not fail because it would
        expose information about registered users.
        """
        data = {'email': '[email protected]'}
        form = PasswordResetForm(data)
        self.assertTrue(form.is_valid())
        self.assertEqual(len(mail.outbox), 0)

Example 49

Project: shuup Source File: test_contact_page.py
@pytest.mark.django_db
def test_admin_recovers_clients_password(rf, admin_user):
    get_default_shop()
    person = create_random_person()
    person.user = get_user_model().objects.create_user(
        username="random_person",
        password="asdfg",
        email="[email protected]"
    )
    person.save()
    request = apply_request_middleware(rf.post("/"), user=admin_user)
    view_func = ContactResetPasswordView.as_view()
    n_outbox_pre = len(mail.outbox)
    view_func(request, pk=person.pk)  # The response doesn't actually matter.
    assert (len(mail.outbox) == n_outbox_pre + 1), "Sending recovery email has failed"

Example 50

Project: django-templated-email Source File: test_views.py
    def test_form_valid_with_send_on_success(self):
        response = AuthorCreateView.as_view()(self.good_request)
        self.assertEquals(response.status_code, 302)
        self.assertEquals(Author.objects.count(), 1)
        self.assertEquals(len(mail.outbox), 1)
        self.assertEquals(mail.outbox[0].alternatives[0][0].strip(),
                          'Andre - [email protected]')
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4