On Wednesday, 7 September 2011 07:49:00 UTC+1, Reikje wrote: > > Hi, I have a bunch of WebTest's which are using the reverse method > from django.core.urlresolvers to resolve a URL which the test should > call. Example: > > url = reverse('webapp_home') > form = self.app.get(url).form > > Now I need to add a query parameter to every url. This is to mimic a > Facebook request which will always have the signed_request query > parameter. So in theory I could just do this: > > url = reverse('webapp_home') + "? > signed_request=vlXgu64BQGFSQrY0ZcJBZASMvYvTHu9GQ0YM9rjPSso.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsIjAiOiJwYXlsb2FkIn0" > > > form = self.app.get(url).form > > This is an example of a signed_request from the Facebook > documentation. Since, I am a bit lazy, is there a way to sort of > intercept all calls to reverse and add the signed_request parameter > every time?
You probably just want to monkeypatch urlresolvers.reverse in your test setUp methods. Something like this would probably work. from django.core import urlresolvers reverse_original = urlresolvers.reverse def reverse(*args, **kwargs): url = reverse_original(*args, **kwargs) url += whatever_you_want_to_add return url urlresolvers.reverse = reverse -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/WRFBNCqIHwoJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.