# HG changeset patch # User Daniele Nicolodi # Date 1313343088 -7200 # Node ID d799c05caaad7ffbf44d0ba137948b18cb1f2d47 # Parent 1e144e9c18477395a3e1dc9848abbf2aef693102 Test user profile operations. diff -r 1e144e9c1847 -r d799c05caaad src/ltpdarepo/tests/browse-user.txt --- /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 + '...
  • This field is required.
  • ...' + +Set email too:: + + >>> browser.getControl(name='email').value = 'u1@example.net' + >>> browser.getControl(name='submit').click() + >>> browser.url + 'http://localhost/user/u1' + >>> browser.contents + '...

    Name:User One

    ...' + >>> browser.contents + '...

    Email:u1@example.net

    ...' + +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: ... diff -r 1e144e9c1847 -r d799c05caaad src/ltpdarepo/tests/test_doctests.py --- 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,