Mercurial > hg > ltpdarepo
changeset 69:d799c05caaad
Test user profile operations.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Sun, 14 Aug 2011 19:31:28 +0200 |
parents | 1e144e9c1847 |
children | e3ca8de73109 |
files | src/ltpdarepo/tests/browse-user.txt src/ltpdarepo/tests/test_doctests.py |
diffstat | 2 files changed, 102 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ltpdarepo/tests/browse-user.txt Sun Aug 14 19:31:28 2011 +0200 @@ -0,0 +1,101 @@ +Test setup:: + + >>> from ltpdarepo.tests.utils import Browser + >>> USERNAME, PASSWORD = 'u1', 'u1' + >>> browser = Browser() + +Login:: + + >>> browser.open('/') + >>> browser.url + 'http://localhost/login' + + >>> browser.getControl(name='username').value = USERNAME + >>> browser.getControl(name='password').value = PASSWORD + >>> browser.getControl(name='login').click() + >>> browser.url + 'http://localhost/' + +View user profile:: + + >>> browser.getLink('u1').click() + >>> browser.url + 'http://localhost/user/u1' + +Edit profile:: + + >>> browser.getLink('Edit profile').click() + >>> browser.url + 'http://localhost/user/u1/edit' + +This should fail because email is required:: + + >>> browser.getControl(name='name').value = 'User' + >>> browser.getControl(name='surname').value = 'One' + >>> browser.getControl(name='submit').click() + >>> browser.url + 'http://localhost/user/u1/edit' + >>> browser.contents + '...<li>This field is required.</li>...' + +Set email too:: + + >>> browser.getControl(name='email').value = 'u1@example.net' + >>> browser.getControl(name='submit').click() + >>> browser.url + 'http://localhost/user/u1' + >>> browser.contents + '...<p class="field"><span class="label">Name:</span>User One</p>...' + >>> browser.contents + '...<p class="field"><span class="label">Email:</span>u1@example.net</p>...' + +Change password:: + + >>> browser.getLink('Change password').click() + >>> browser.url + 'http://localhost/user/u1/password' + + >>> browser.getControl(name='password').value = 'new' + >>> browser.getControl(name='confirm').value = 'new' + >>> browser.getControl(name='submit').click() + >>> browser.url + 'http://localhost/user/u1' + +Logout and login again with the new credentials:: + + >>> browser.getLink('logout').click() + >>> browser.url + 'http://localhost/login' + + >>> browser.getControl(name='username').value = USERNAME + >>> browser.getControl(name='password').value = 'new' + >>> browser.getControl(name='login').click() + >>> browser.url + 'http://localhost/' + +Trying to view or edit an unexisting user profile results in an error:: + + >>> browser.open('/user/u2') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 403: ... + +Check that we can not edit someone else profile:: + + >>> from ltpdarepo.admin import useradd + >>> useradd('u2', 'u2') + + >>> browser.open('/user/u2') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 403: ... + + >>> browser.open('/user/u2/edit') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 403: ... + + >>> browser.open('/user/u2/password') + Traceback (most recent call last): + ... + HTTPError: HTTP Error 403: ...
--- a/src/ltpdarepo/tests/test_doctests.py Sun Aug 14 19:31:28 2011 +0200 +++ b/src/ltpdarepo/tests/test_doctests.py Sun Aug 14 19:31:28 2011 +0200 @@ -20,6 +20,7 @@ suite = unittest.TestSuite() suite.addTest( doctest.DocFileSuite( + 'browse-user.txt', 'manage-users.txt', 'manage-databases.txt', setUp=doctestSetUp, tearDown=doctestTearDown,