You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
936 B
34 lines
936 B
7 years ago
|
''' Tests for ordr2.security '''
|
||
|
|
||
|
import pytest
|
||
|
|
||
|
from pyramid.testing import DummyRequest
|
||
|
from pyramid_mailer import get_mailer
|
||
|
|
||
|
from . import app_config, get_user
|
||
|
|
||
|
|
||
|
def test_user_notification_init():
|
||
|
''' test creation of user notification events '''
|
||
|
from ordr2.events import UserNotification
|
||
|
|
||
|
notification = UserNotification('a', 'b', 'c')
|
||
|
|
||
|
assert notification.request == 'a'
|
||
|
assert notification.account == 'b'
|
||
|
assert notification.data == 'c'
|
||
|
|
||
|
|
||
|
def test_notify_user(app_config):
|
||
|
from ordr2.events import CompleteRegistration, notify_user
|
||
|
|
||
|
request = DummyRequest()
|
||
|
user = get_user('user')
|
||
|
notification = CompleteRegistration(request, user, {'hash': 'something'})
|
||
|
notify_user(notification)
|
||
|
mailer = get_mailer(request.registry)
|
||
|
last_mail = mailer.outbox[-1]
|
||
|
|
||
|
assert 'Please verify your email address ' in last_mail.html
|
||
|
assert 'http://example.com//something' in last_mail.html
|