testing controllers with enabled identity

0 views
Skip to first unread message

Diez B. Roggisch

unread,
Dec 6, 2006, 8:39:23 AM12/6/06
to TurboGears
Hi all,

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

Max Ischenko

unread,
Dec 13, 2006, 4:40:43 AM12/13/06
to TurboGears
Hi,

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.

felix....@web.de

unread,
Dec 14, 2006, 3:11:24 AM12/14/06
to TurboGears
Hi Diez,

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

Diez B. Roggisch

unread,
Dec 18, 2006, 10:49:07 AM12/18/06
to turbo...@googlegroups.com

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

Max Ischenko

unread,
Dec 24, 2006, 9:16:49 AM12/24/06
to TurboGears
FWIW, the patch has been merged in TG 1.0 stable branch.

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,

Reply all
Reply to author
Forward
0 new messages