Hi,
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
email
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('http://127.0.0.1:8000/welcome/default/')
client.get('user/register')
data = dict(first_name = 'Homer',
last_name = 'Simpson',
email = '[email protected]',
password = 'test',
password_two = 'test',
_formname = 'register') # (*)
client.post('user/register',data = data)
data = dict(email='[email protected]',
password='test',
_formname = 'login')
client.post('user/login',data = data)
client.get('index')
# 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
client.get('index')
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
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.