|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
import pytest |
|
|
|
import pytest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from datetime import datetime |
|
|
|
from pyramid.testing import DummyRequest |
|
|
|
from pyramid.testing import DummyRequest |
|
|
|
from pyramid_mailer import get_mailer |
|
|
|
from pyramid_mailer import get_mailer |
|
|
|
|
|
|
|
|
|
|
@ -21,13 +22,15 @@ def test_user_notification_init(): |
|
|
|
|
|
|
|
|
|
|
|
def test_notify_user(app_config): |
|
|
|
def test_notify_user(app_config): |
|
|
|
from ordr2.events import CompleteRegistration, notify_user |
|
|
|
from ordr2.events import CompleteRegistration, notify_user |
|
|
|
|
|
|
|
from ordr2.models.account import Token |
|
|
|
|
|
|
|
|
|
|
|
request = DummyRequest() |
|
|
|
request = DummyRequest() |
|
|
|
user = get_user('user') |
|
|
|
user = get_user('user') |
|
|
|
notification = CompleteRegistration(request, user, {'hash': 'something'}) |
|
|
|
token = Token(expires=datetime.utcnow(), hash='some_hash') |
|
|
|
|
|
|
|
notification = CompleteRegistration(request, user, {'token': token}) |
|
|
|
notify_user(notification) |
|
|
|
notify_user(notification) |
|
|
|
mailer = get_mailer(request.registry) |
|
|
|
mailer = get_mailer(request.registry) |
|
|
|
last_mail = mailer.outbox[-1] |
|
|
|
last_mail = mailer.outbox[-1] |
|
|
|
|
|
|
|
|
|
|
|
assert 'Please verify your email address ' in last_mail.html |
|
|
|
assert 'Please verify your email address ' in last_mail.html |
|
|
|
assert 'http://example.com//something' in last_mail.html |
|
|
|
assert 'http://example.com//some_hash' in last_mail.html |
|
|
|