I think you are going to like this:
https://github.com/web2py/web2py/blob/master/gluon/contrib/webclient.py
start web2py on port 8000. Then in a normal python shell:
from gluon.contrib.webclient import WebClient
session = WebClient('http://127.0.0.1:8000/welcome/default/')
session.get('user/register')
session_id_welcome = session.cookies['session_id_welcome']
print session.forms # tells you which forms are in page (*)
data = dict(first_name = 'Homer',
last_name = 'Simpson',
email = '[email protected]',
password = 'test',
password_two = 'test',
_formname = 'register') # (*)
session.post('user/register',data = data)
session.get('user/login')
data = dict(email='[email protected]',
password='test',
_formname = 'login')
session.post('user/login',data = data)
session.get('index')
# check registration and login were successful
assert 'Welcome Homer' in session.text
# check we are always in the same session
assert session_id_welcome == session.cookies['session_id_welcome']
It understand sessions (not just web2py session)
It understands basic auth (not used in the example)
It understands web2py forms (*) and fills in the _formkeys.
Suggestions for improvement?
Massimo
--