Already tried login_bare too... still not working...
Em segunda-feira, 3 de novembro de 2014 10h32min47s UTC-2, Pedro Henrique
Correa Ferreira escreveu:
>
> Hello, buddies
>
> I'd like to know how can I run a Unittest in a fuction that requires
> permission.
>
> The function is the following:
>
> @auth.requires_permission('accessible', URL(request.controller,'pessoa'))
> def pessoa():
> print URL(request.controller,'pessoa')
> grid = SQLFORM.grid(db.pessoa, formstyle = 'bootstrap')
> form=SQLFORM(db.pessoa).process()
> return locals()
>
>
> While the unittest code is:
>
> # coding: utf8
> import unittest, types
> from gluon.globals import Request
> from gluon.storage import Storage
> execfile("applications/novo/controllers/plugin_00030_crm.py", globals())
> class testPessoa(unittest.TestCase):
> def setUp(self):
> request = Request({})
> auth.user = Storage(dict(id=1))
> def testPessoa(self):
> resp = pessoa()
> self.assertEquals(True, isinstance(resp, types.DictType))
> self.assertEquals(True, "grid" in resp.keys())
> suite = unittest.TestSuite()
> suite.addTest(unittest.makeSuite(testPessoa))
> unittest.TextTestRunner(verbosity=2).run(suite)
>
>
>
>
> I've entered in the db table "auth_permission" and created the following
> record:
>
> group_id: "ADMINISTRADOR (1)"
> name: "accessible"
> Object or table name: "/novo/plugin_00030_crm/pessoa"
> Record id: "0"
>
> It was supposed to work, but still returning HTTP 303.
>
> How do I fix this?
>
> Sorry if this is a duplicated post.
>
> Cheers,
>
> Pedro.
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.