On Thu, Dec 18, 2008 at 4:14 PM, Ben Bangert <[email protected]> wrote:
> On Dec 18, 2008, at 7:55 AM, Jorge Vargas wrote:
>
>> Hi, I'm writing unit tests and I was wondering if there is a way to
>> ask routes for all possible urls it can handle. if this is not, there
>> how hard will it be to implement? Ideally I want to mix this with
>> webtest so I can have a generic test that will tell me if all urls I'm
>> calling are ok, by ok I mean no 400 or 500 errors, I know this is
>> going to be harder for the POSTs but for all the GETs it should be a
>> nice addition to the testsuite.
>
> Sort of. You can get all the routes out, and the paths that you setup,
> that's about it. You'd have to crawl all your controllers, and find all
> methods that could be gotten to publicly to find every execution path
> though.... not exactly ideal.

yea I think that is what I'll ultimately do if there isn't a better
solution. I honestly don't know routes well enough to know if this is
even possible. One alternative solution will be to find all calls to
url_for and try to execute them, the other will be to track the
@expose, that should give you at least a set where to start that could
be manually edited to add proper fields.

for example /foo/:bar will be "catch" by the analyzer, then you could
replace that for a set of valid urls that match your test environment,
like if :bar is a field in the db, then you could replace that with
/foo/validTestData1, /foo/validTestData2, /foo/IDontExist,
/foo/validTestData1/, /foo/validTestData2/,, and then pass that list
to something like what Mike suggested.

>
> Cheers,
> Ben

--~--~---------~--~----~------------~-------~--~----~
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