[Zope3-Users] Doctests and authenticated principal
Maciej Wisniowski
maciej.wisniowski at coig.katowice.pl
Wed Jan 31 05:28:12 EST 2007
Hi
I'm writing doctest using DocFileSuite.
Code that I'm testing needs information
about currently authenticated principal.
It uses: request.principal.id to get it.
In doc test I may use:
>>> request = TestRequest()
>>> class User(object):
... id = 'Jan'
... title = 'Jan Kowalski'
>>> request.setPrincipal(User())
..........rest of the test......
and after this everything works.
Is this correct way?
I also have some code that uses:
from zope.app.security.interfaces import ILoginPassword
ILoginPassword(self.request).getLogin()
During tests, I always get None as result of the above
statement.
So another question, what is the correct way to
get currently authenticated principal id:
request.principal.id or ILoginPassword(self.request).getLogin()?
--
Maciej Wisniowski
More information about the Zope3-users
mailing list