Does anyone know how to unit test the auth functions in web2py?

If so, could you please send examples?

So far, using the example unit test provided here:
http://www.web2py.com/AlterEgo/default/show/213 as the basis, I've
attempted to call http://site/default/user/register.

Here's an example:

class TestDefaultController(unittest.TestCase):
    def testRegisterGet_noKeys(self):
        self.request.env.request_method = 'GET'
        self.request.vars = None
        self.controller.user('register')
        form = self.controller.user('register').response._vars['form']
        self.assertFalse(form.errors)


I've tried some obvious permutations of the line:
        self.controller.user('register')
like:
        self.controller.user.register
        self.controller.user(register)

But to no avail, so far.

Naturally, for the 2 examples above that are passing an arg I changed
the default.py user function to be:

     def user(arg=None):
          return dict(form=auth())

but, oddly, I get the following error when I've tried passing
'register' as an arg:

NameError: global name 'auth' is not defined

Also, I've already checked the projects source tree for existing unit
tests for auth.

Thanks in advance to anyone that provides insight and examples on how
to this. :-)










--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to