Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jwag956 committed Apr 29, 2019
1 parent 8806a4a commit 3dee03d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
RegisterForm, ResetPasswordForm, SendConfirmationForm, StringField, \
email_required, email_validator, valid_user_email
from flask_security.utils import capture_reset_password_requests, \
encode_string, hash_data, string_types, verify_hash
encode_string, hash_data, send_mail, string_types, verify_hash


@pytest.mark.recoverable()
Expand Down Expand Up @@ -280,3 +280,23 @@ class MyRegisterForm(RegisterForm):
def test_without_babel(client):
response = client.get('/login')
assert b'Login' in response.data


def test_no_email_sender(app):
""" Verify that if SECURITY_EMAIL_SENDER is default
(which is a local proxy) that send_mail picks up MAIL_DEFAULT_SENDER.
"""
app.config['MAIL_DEFAULT_SENDER'] = 'test@testme.com'

class TestUser(object):
def __init__(self, email):
self.email = email
security = Security()
security.init_app(app)

with app.app_context():
user = TestUser('matt@lp.com')
with app.mail.record_messages() as outbox:
send_mail('Test Default Sender', user.email, 'welcome', user=user)
assert 1 == len(outbox)
assert 'test@testme.com' == outbox[0].sender

0 comments on commit 3dee03d

Please sign in to comment.