[web2py] Re: Test controller again

2011-01-27 Thread howesc
to enhance massimo's response, you can test the HTTP status code in the except block: >>> try: ... index() ... except HTTP, e: ... assert(e.status == 400) ... assert(e.body == "Not permitted") ...

[web2py] Re: Test controller again

2011-01-27 Thread Massimo Di Pierro
def show(): """ >>> request.args.clear() >>> try: print show() >>> except HTTP, http: print 'ok' ok """     if request.args(0) == None:         redirect(URL('index')) On Jan 27, 4:08 am, walter wrote: > Excuse me. May be I'm stupid, but I don't understand how to test next

[web2py] Re: Test controller

2011-01-15 Thread walter
I have another one question. How to interact with controller in shell?

[web2py] Re: Test controller

2011-01-15 Thread Massimo Di Pierro
for example: def index(): """ >>> request.vars.update(title='xxx' >>> assert(len(index()['articles'].find(r:r['title']=='xxx'))==1) >>> db(db.article.title=='xxx').delete() 1 """ form = SQLFORM(db.article) if form.accepts(request.vars): response.flash = "óÔÁÔØÑ ÄÏÂÁ