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.
59 lines
2.2 KiB
59 lines
2.2 KiB
7 years ago
|
''' functional tests for ordr2.views.registration '''
|
||
|
|
||
7 years ago
|
from pyramid_mailer import get_mailer
|
||
|
|
||
|
from . import testappsetup, testapp, get_token_url # noqa: F401
|
||
7 years ago
|
|
||
|
|
||
|
def test_registration_form(testapp): # noqa: F811
|
||
7 years ago
|
''' test the registration form '''
|
||
7 years ago
|
response = testapp.get('/account/register')
|
||
7 years ago
|
active = response.html.find('li', class_='active')
|
||
7 years ago
|
assert active.a['href'] == 'http://localhost/account/register'
|
||
7 years ago
|
assert 'Registration' in response.html.title.text
|
||
7 years ago
|
|
||
|
|
||
|
def test_registration_form_invalid(testapp): # noqa: F811
|
||
7 years ago
|
''' test the registration form with invalid data '''
|
||
7 years ago
|
response = testapp.get('/account/register')
|
||
|
|
||
7 years ago
|
form = response.form
|
||
|
form['email'] = 'not an email address'
|
||
|
response = form.submit(name='create')
|
||
7 years ago
|
|
||
7 years ago
|
assert 'Invalid email address' in response
|
||
7 years ago
|
assert 'Registration' in response.html.title.text
|
||
7 years ago
|
|
||
|
|
||
|
def test_registration_process(testapp): # noqa: F811
|
||
7 years ago
|
''' test the registration process with valid data '''
|
||
7 years ago
|
response = testapp.get('/account/register')
|
||
|
|
||
7 years ago
|
form = response.form
|
||
|
form['username'] = 'AmyMcDonald',
|
||
|
form['first_name'] = 'Amy',
|
||
7 years ago
|
form['last_name'] = 'McDonald',
|
||
7 years ago
|
form['email'] = 'amy.mcdonald@example.com',
|
||
|
form['password'] = 'Make Amy McDonald A Rich Girl Fund',
|
||
|
form['password-confirm'] = 'Make Amy McDonald A Rich Girl Fund',
|
||
|
response = form.submit(name='create')
|
||
7 years ago
|
assert response.location == 'http://localhost/account/register/verify'
|
||
|
|
||
7 years ago
|
response = response.follow()
|
||
7 years ago
|
active = response.html.find('li', class_='active')
|
||
7 years ago
|
assert active.a['href'] == 'http://localhost/account/register'
|
||
7 years ago
|
assert 'Please follow the link in the email' in response
|
||
7 years ago
|
assert 'Registration' in response.html.title.text
|
||
7 years ago
|
|
||
7 years ago
|
# click the email verification token
|
||
|
mailer = get_mailer(testapp.app.registry)
|
||
|
email = mailer.outbox[-1]
|
||
|
assert email.subject == '[ordr] Please verify your email address'
|
||
7 years ago
|
|
||
|
token_link = get_token_url(email, prefix='/account/register/')
|
||
7 years ago
|
response = testapp.get(token_link)
|
||
7 years ago
|
active = response.html.find('li', class_='active')
|
||
7 years ago
|
assert active.a['href'] == 'http://localhost/account/register'
|
||
7 years ago
|
assert 'Registration Completed' in response
|
||
7 years ago
|
assert 'Registration' in response.html.title.text
|