I'm creating tests for paginate.py. Initially, I wanted to call
methods directly like so:
response = testutil.call(self.root.page_list, tg_paginate_limit=11)
But I got this error:
AttributeError: DummyRequest instance has no attribute
'object_trail'
which comes from the check_app_root function in controllers.py
I then checked out the documentation and discovered call_with_request,
which seemed like what I needed. But I'm not sure how to create a
request. I tried
testutil.create_request(url)
and used cherrypy.request, but I got infinite recursion with this:
testutil.call_with_request(self.root.page_list, cherrypy.request,
tg_paginate_limit=11)
I'm sure I'm not using it properly, but I haven't figured it out and
the docs don't talk about how to create a request object.
Finally, I tried a nasty hack. The method I'm calling has no template
so this:
testutil.create_request(url)
gives me access to cherrypy.request.body[0], which contains the methods
return value in a string, which I can parse. Workable, but I still
have a problem. My input values are not getting through. If I call
this url.
url = '/page_list?tg_paginate_limit=11'
tg_paginate_limit is present in cherrypy.request.params, but is not
available as a keyword in the "decorated" function of paginate.py (line
16). I know it is available in a real application because I've written
some, but for some reason using testutil.create_request doesn't seem to
behave as expected.
Another oddity is when I change the order of the decorators expose and
paginate, paginate doesn't paginate the data.
I'll attach the test if Google Groups allows attachments.
Randall
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---