예제 #1
0
파일: view.py 프로젝트: marcio0/niqels
    def test_email_users(self, send_mass_mail):
        data = {'title': 'yeah', 'content': 'message'}
        form = UserQueryForm(data)

        user_1 = User(email='*****@*****.**')
        user_2 = User(email='*****@*****.**')
        user_3 = User(email='*****@*****.**')

        view = EmailInterface()
        view.users_result = [user_1, user_2, user_3]

        view.email_users(form)

        admin_emails = []
        for admin in settings.ADMINS:
            admin_emails.append(admin[1])

        messages = [(data['title'], data['content'], '*****@*****.**',
                     [user_1.email]),
                    (data['title'], data['content'], '*****@*****.**',
                     [user_2.email]),
                    (data['title'], data['content'], '*****@*****.**',
                     [user_3.email]),
                    (data['title'] + ' (sent from admin panel)',
                     data['content'], '*****@*****.**', admin_emails)]

        send_mass_mail.assert_called_with(messages)
예제 #2
0
파일: view.py 프로젝트: marcio0/niqels
    def test_email_users(self, send_mass_mail):
        data = {
            'title': 'yeah',
            'content': 'message'
        }
        form = UserQueryForm(data)

        user_1 = User(email='*****@*****.**')
        user_2 = User(email='*****@*****.**')
        user_3 = User(email='*****@*****.**')

        view = EmailInterface()
        view.users_result = [user_1, user_2, user_3]

        view.email_users(form)

        admin_emails = []
        for admin in settings.ADMINS:
            admin_emails.append(admin[1])

        messages = [
            (data['title'], data['content'], '*****@*****.**', [user_1.email]),
            (data['title'], data['content'], '*****@*****.**', [user_2.email]),
            (data['title'], data['content'], '*****@*****.**', [user_3.email]),

            (data['title'] + ' (sent from admin panel)', data['content'], '*****@*****.**', admin_emails)
        ]

        send_mass_mail.assert_called_with(messages)
예제 #3
0
파일: view.py 프로젝트: marcio0/niqels
    def test_email_error(self, mass_mail):
        data = {'title': 'yeah', 'content': 'message'}
        form = UserQueryForm(data)

        user_1 = User(email='*****@*****.**')

        view = EmailInterface()
        view.users_result = [user_1]

        mass_mail.side_effect = SMTPException('fail')

        view.email_users(form)

        self.assertEquals(form.errors['__all__'], 'error sending email: fail')
예제 #4
0
파일: view.py 프로젝트: marcio0/niqels
    def test_email_error(self, mass_mail):
        data = {
            'title': 'yeah',
            'content': 'message'
        }
        form = UserQueryForm(data)

        user_1 = User(email='*****@*****.**')

        view = EmailInterface()
        view.users_result = [user_1]

        mass_mail.side_effect = SMTPException('fail')

        view.email_users(form)

        self.assertEquals(form.errors['__all__'], 'error sending email: fail')