One trick is to replace

@auth.requires_login()

with

@auth.requires(auth.user or request.function=='_TEST')


On Feb 16, 7:33 am, Oskari <[email protected]> wrote:
> Hi,
>
> I'm writing doctests to my application. Most of my functions are
> decorated with @auth.requires_login().
>
> Running doctests through the web IDE runs the tests in a different
> environment depending on if I'm logged in in the app.
> What kind of pattern is here meant to be used to test logged-in
> features (the normal usage) possibly without self first logging in
> through the app?
> And also of course test that you cannot access the function without
> logging in?
>
> And also, considering an app with no data in database, how to test for
> example empty forms and lists easily?
>
> I am a bit confused with the way web2py is really supposed to be
> tested, the book lacks examples and discussion on that.
>
> Thanks already!

Reply via email to