I made a slice: http://www.web2pyslices.com/main/slices/take_slice/67
I'll post a project also to bitbucket. I've created a unit system but I made a lot of assumptions and I think that we should talk about it: First, I created a testRunner.py file (in the same directory level with web2py.py) that runs ALL tests that exist in the tests directory of an app. Don't know whether it should stay there (or go to gluon) but it's application-agnostic (reads the args when it's called and runs only the tests of the specific application). And with one command, you run ALL your tests (without needing any configuration). Just add tests, inside the tests directory. Then, I copied a file that is need for posting to forms to gluon.contrib. Now, the structure is this: applications/appname/tests/controllers/controller_name.py or applications/appname/tests/models/model_name.py or whatever The controller_name should be the same with the controller we are unittesting (it's "imported" automatically). The class name should be ControllernameController (feels like Rails, I know). It's automatically inserted to unittesting also. Have in mind that it's Controller NOT Controllers. So, any ideas? PS: Does forms, auth and database testing On Mar 2, 4: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 dounittestingon 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. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.