On Wed, 2010-12-22 at 19:45 -0800, jerry wrote:
> Hi,
> 
> I have the following URL dispatch setup --
> 
> <__init__.py>
> config.add_route('user', '/user')
> config.add_route('user_id', '/user/{user_id}')
> config.scan()
> </__init.py__>
> 
> <views/user.py>
> @view_config(route_name='user', renderer='user.genshi')
> @view_config(route_name='user_id', renderer='user_id.genshi')
> def user_view(request):
> </views/user.py>
> 
> which works fine.
> 
> However, my unit test case always gets routed to 'user' instead of
> 'user_id' no matter how I tweak the request.path_info --
> 
> <test_user_view.py>
> request = DummyRequest()
> request.path_info = route_url('user_id', request, user_id=u'42')
> #request.path_info = '/user/42'
> resp = views.user.user_view(request)
> </test_user_view.py>
> 
> I'm sure I must be missing something very simple there.

"route_url" returns a fully qualified URL (with host, scheme, port,
path).  You probably want "route_path".  Not sure if this is the problem
you're writing about, but it's *a* problem.

I actually don't understand the question, to be honest.  You're
explicitly calling user_view.  No routing is actually happening; you're
not running a request through the "router".  What are you trying to
test?  If you're trying to write a functional test, do it like this
instead:

file:///home/chrism/projects/pyramid/docs/_build/html/narr/testing.html#creating-functional-tests

- C


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to