Thank you very much for this. I've been wanting to integrate unit tests in my project but didn't found the time to investigate this issue.
Best regards, Tiago --- On Tue, Mar 2, 2010 at 2:41 PM, spiffytech <spiffyt...@gmail.com> wrote: > I finally finished the article I promised. I couldn't post to the > wiki, so I posted to AlterEgo instead: > > http://web2py.com/AlterEgo/default/show/260 > > Since I've done little with web2py forms and auth, they're not > covered. Feel free to change the article to include how to test them. > > > On Mar 2, 8:59 am, Jon Romero <darks...@gmail.com> wrote: > > I'll post a full example in bitbucket and then a slice :) > > > > On Mar 2, 2:30 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > Would you post a web2pyslice? > > > > > On Mar 2, 4:39 am, Jon Romero <darks...@gmail.com> wrote: > > > > > > ok I managed to do unit testing on forms: > > > > > > def testForm(self): > > > > request.vars["username"] = "great-guy" > > > > request.vars["email"] = "b...@bla.com" > > > > > > request.vars["_formname"] = "bla_create" #this is the form > > > > name > > > > > > resp = index() > > > > > > self.assertTrue(resp['form'].errors) # do we have errors? > > > > self.assertEquals(1, len(resp["all_users"])) > > > > > > On Mar 1, 2:20 pm, Jon Romero <darks...@gmail.com> wrote: > > > > > > > Good job! > > > > > > > I am still having problem withunittestingforms. It seems that I > > > > > cannot do a post. > > > > > > > # Set variables for the test function > > > > > request.env.request_method = 'POST' > > > > > request.post_vars["body"] = "body" > > > > > #request.vars = Storage(body = "bodyyyy") > > > > > > > resp = index() > > > > > print "vars", resp['form'] > > > > > > > #self.assertTrue(resp['form'].errors) # do we have errors? > > > > > #self.assertTrue(resp['form'].errors.has_key('name')) # is > > > > > something missing? > > > > > > > Any ideas? > > > > > > > On Feb 25, 11:15 pm, Jonathan Lundell <jlund...@pobox.com> wrote: > > > > > > > > I'm really glad to see this work happening, and I look forward to > the slice. > > > > > > > > Perhaps we could eventually haveunittests as part of the welcome > app, or indeed all three standard apps, both for documentation purposes and > to set a good example. > > -- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To post to this group, send email to web...@googlegroups.com. > To unsubscribe from this group, send email to > web2py+unsubscr...@googlegroups.com<web2py%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/web2py?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.