I'm trying to test my controllers with enabled identity-checking - so far to
no avail. I found this patch:
http://trac.turbogears.org/turbogears/attachment/ticket/1166/test_id.patch
but I didn't figure out a way to actually make my test_controllers.py working
with that.
Anybody here having success testing with identity support?
--
>> Diez B. Roggisch
>> Developer
T +49 (30) 443 50 99 - 27
F +49 (30) 443 50 99 - 99
M +49 (179) 11 75 303
E diez.r...@artnology.com
>> artnology GmbH
A Milastraße 4 / D-10437 Berlin
T +49 (30) 443 50 99 - 0
F +49 (30) 443 50 99 - 99
E in...@artnology.com
I http://www.artnology.com
Have you tried to apply the patch and then call
testutil.set_identity_user() method?
What exactly the problem you run into?
Max,
patch author.
after some source code reading, I got this working. I guess your main
problem is that call() and call_with_request() use the method directly
but identity support is implemented via cherrypy's filter mechanism.
These filters (especially "before_main") are only run if you use the
"normal" way calling cherrypy. In these filters request.identity is
set. The easiest way I found so far was to call
apply_filters("before_main") manually just before call_with_request.
fs
Thanks for your reply - it didn't work for me though, as so far I use
create_request
which actually _does_ run all the filtering stuff. And while there is the
test_user attached to the request, the identity is somehow removed and the
later VisitFilter will not find a suitable identity and thus redirect to the
login page.
Hrmpf. I'll see if I can get that working, but it's actually much more
(black...) magic than I'm currently interesting in tinkering with. I'm at my
first, maximum second Hogwarts year...
Diez
Now your identity tests should be as simple as
fred = User.get(...)
testutil.set_identity_user(fred)
#use call/call_with_request()
See
http://maxischenko.in.ua/blog/entries/112/turbogears-identity-testing-hooks/
Max,