Cool, but I was no longer in gluon? Or it's a change? Em quarta-feira, 29 de agosto de 2012 19:49:14 UTC-3, Massimo Di Pierro escreveu: > > 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 = 'ho...@web2py.com <javascript:>', > password = 'test', > password_two = 'test', > _formname = 'register') # (*) > session.post('user/register',data = data) > > session.get('user/login') > data = dict(email='ho...@web2py.com <javascript:>', > 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 > >
-- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.