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.

63 lines
1.9 KiB

''' tests for the login, logout, registration and account settings'''
import pytest
from pyramid_mailer import get_mailer
from . import testapp, get_token_url
from .. import get_user
def test_account_settings(testapp):
''' changing password and email address '''
# log in
testapp.login('user')
# change the password
response = testapp.get('/account/settings')
form = response.forms[0]
form['new_password'] = 'The Spanish Inquisition'
form['new_password-confirm'] = 'The Spanish Inquisition'
form['password'] = 'Terry'
response = form.submit()
assert response.location == 'http://localhost/'
response = testapp.get('/account/login')
assert 'Password updated sucessfully' in response
# login with new password
testapp.logout()
response = testapp.get('/account/login')
form = response.forms[0]
form['username'] = 'TerryGilliam'
form['password'] = 'The Spanish Inquisition'
form.submit()
response = testapp.get('/account/login')
assert '<!-- user is logged in -->' in response
# change the email address
response = testapp.get('/account/settings')
form = response.forms[0]
form['email'] = 'amy@example.com'
form['password'] = 'The Spanish Inquisition'
response = form.submit().follow()
assert 'Verify Your Email Address' in response
# check the email with verification token
mailer = get_mailer(testapp.app.registry)
email = mailer.outbox[-1]
assert email.subject == '[ordr] Please verify your email address'
# click the email verification token
token_link = get_token_url(email)
response = testapp.get(token_link)
assert response.location == 'http://localhost/'
response = testapp.get('/account/login')
assert 'Email change sucessful' in response
# check tat the email address was changed
response = testapp.get('/account/settings')
assert 'value="amy@example.com"' in response