CPI Ordering System (the old version)
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

48 lines
1.5 KiB

''' functional tests for ordr2.views.registration '''
from pyramid_mailer import get_mailer
from . import testappsetup, testapp, get_token_url # noqa: F401
def test_registration_form(testapp): # noqa: F811
response = testapp.get('/register')
active = response.html.find('li', class_='active')
assert active.a['href'] == '/register'
def test_registration_form_invalid(testapp): # noqa: F811
response = testapp.get('/register')
form = response.form
form['email'] = 'not an email address'
response = form.submit(name='create')
assert 'Invalid email address' in response
def test_registration_process(testapp): # noqa: F811
response = testapp.get('/register')
form = response.form
form['username'] = 'AmyMcDonald',
form['first_name'] = 'Amy',
form['last_name'] = 'Mc Donald',
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')
assert response.location == 'http://localhost/register/verify'
response = response.follow()
assert 'Please follow the link in the email' in response
# click the email verification token
mailer = get_mailer(testapp.app.registry)
email = mailer.outbox[-1]
assert email.subject == '[ordr] Please verify your email address'
token_link = get_token_url(email, prefix='/register/')
response = testapp.get(token_link)
assert 'Registration Completed' in response