Holger Frey
7 years ago
3 changed files with 173 additions and 1 deletions
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
''' 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 |
Reference in new issue