i am testing my app with Massimo's webclient. I did some requests and 
everything went fine but I can't login users either with their username or 
I use the same code as below :
I get a client.status=200 but the assert Welcome fails ?
I printed client.text and searched manually for the 'Welcome ....'. Indeed 
no Welcome

In 2.0.2 it is even simpler:

    from gluon.contrib.webclient import WebClient

    client = WebClient('')


    data = dict(first_name = 'Homer',
                last_name = 'Simpson',
                email = 'ho...@web2py.com',
                password = 'test',
                password_two = 'test',
                _formname = 'register')  # (*)
    client.post('user/register',data = data)

    data = dict(email='ho...@web2py.com',
                _formname = 'login')
    client.post('user/login',data = data)

    # check registration and login were successful
    assert 'Welcome Homer' in client.text

Checks automatically for persistant sessions and raises exception if sessions 
break or if a web ticket is issued.
You can also do

    print client.headers
    print client.cookies # parsed as a dict
    print client.forms # dict of formname:formvalue
    print client.sessions # dict of appname:session_cookie_key
    print client.status
    print client.text

- 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.

Reply via email to