[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 wdv...@gmail.com wrote:
 Excuse me. May be I'm stupid, but I don't understand how to test next
 case. I want to test that a response.status really has 303.

 Bit of my code:

 def show():
     if request.args(0) == None:
         redirect(URL('index'))

 How should I write a doctest for this?


[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

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 = óÔÁÔØÑ
ÄÏÂÁ×ÌÅÎÁ
articles = db().select(db.article.ALL)
return dict(articles=articles, form=form)


On Jan 15, 7:29 am, walter wdv...@gmail.com wrote:
 This is my code
 def index():
     form = SQLFORM(db.article)
     if form.accepts(request.vars): response.flash = óÔÁÔØÑ ÄÏÂÁ×ÌÅÎÁ

     articles = db().select(db.article.ALL)
     return dict(articles=articles, form=form)

 I can't understand how to test index? How to test articles value for
 example?


[web2py] Re: Test controller

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